-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes LListFormats #75
Conversation
We're throwing away here the different between a field missing and a field being set to null. |
sjson-new already doesn't distinguish them in |
In the future when we can break bincompat we could return |
I'm saying for any consumer of Unbuilder, both in and out if this repo, not just OptionFormat; it's kind of evident from your "Increase tolerance to JNull" commit. |
Btw, I'm not saying that And it lends itself better to when we fix this properly to return Option. |
This situation only comes up if you ever pass in explicit list of field names. The only user that does such a thing is us decoding LList. |
... and FlatUnionFormats (which btw we want to check for when empty collections are written, because I see a Let's discuss the other side: what reasons do you have to use |
Java |
case (k, Some(v)) => (k, v) | ||
case (k, None) => (k, facade.jnull()) | ||
} | ||
case ctx: UnbuilderContext.ObjectContext[J] => ctx.next |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dwijnand Not sure if this is what you were talking about, but no more null
or JNull
with this solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opt is not what I meant, but it's the even better solution. Man, we've spent so much time with the liberty of breaking APIs that our bincompat game is weak!
Lgtm
if (!unbuilder.isInObject) objectPreamble(js) | ||
if (unbuilder.hasNextField) { | ||
val (name, optX) = unbuilder.nextFieldOpt | ||
optX map { x => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foreach over map
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
2ad097a
to
5b04c3f
Compare
This is a continuation of #74 by @dwijnand
When we detect an elided field (a field that's in the "fields" list, but missing from JSON object), the unbuilder will now return
JNull
. This should be fine because we also encodeOption[A]
by not writing out the field when possible, and there's no special meaning attached to JSONnull
.