-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Accept JsonTypeInfo.As.WRAPPER_ARRAY
with no second argument to deserialize as "null value"
#2467
Comments
Hmmh. Interesting. I think I would consider improvement here, and PR would be welcome. As to value to pass, I don't think But I think that taking
to be equivalent to
is reasonable and I'm ok accepting possible down-the-line complications that might arise (esp. as I can't think of what those would be) |
Thanks for your quick reply and predisposition to include this change! I tried passing a jackson-databind/src/main/java/com/fasterxml/jackson/databind/JsonDeserializer.java Lines 100 to 104 in 55e8d23
On the other hand, I think calling I added a couple of tests but I'm not sure if they fit your structure. I also haven't checked for failure cases. Let me know! |
Good point on Only one other thing, then: if we do not yet have a CLA for you (one is enough), we would need one; it can be found here: https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf and usual way is to print, fill & sign, scan, email to |
Thank you, sir! The CLA is sent, and the PR to the |
JsonTypeInfo.As.WRAPPER_ARRAY
with no second argument to deserialize as "null value"
Hi!
At RSK we're trying to map Ethereum PUB-SUB JSON-RPC API requests.
We got stuck trying to map the
eth_subscribe
parameters, here are two examples:As you can see, the
params
type is given by the first parameter, so we thought we could do something like this:While everything worked perfectly for
logs
, theAsArrayTypeDeserializer
wasn't able to deserializenewHeads
because it doesn't have an object with extra parameters. It fails on:jackson-databind/src/main/java/com/fasterxml/jackson/databind/jsontype/impl/AsArrayTypeDeserializer.java
Line 110 in bf00c2d
We then tried to implement
DeserializationProblemHandler#handleUnexpectedToken
and build the expected instance ourselves, but the workaround doesn't work because the code expectsp.nextToken() != JsonToken.END_ARRAY
even if the instance was created successfully.Now we'll try a different approach without
JsonTypeInfo.As.WRAPPER_ARRAY
, but it would be amazing if this simple case could be handled. I would suggest treating no value as{}
.If you would be interested in me contributing this feature, please advise how I could approach it. I'd be happy to send a PR.
Cheers!
The text was updated successfully, but these errors were encountered: