Map deserialization inside objects
See original GitHub issueAs mentioned in gitter:
Exception raised when trying to pass in a Map via a mutation:
mutation isoCountryUpdate {
isoCountryUpdate(input: {
clientMutationId: "1234"
isoCountry: {
id: 2747
codeAlpha2: "YY"
codeAlpha3: "YYY"
name: "TEST"
codeNumeric: "66"
confirmationResponses: {key: "TEST", value: "NO"}
}
}) {
clientMutationId
result {
id
name
}
}
}
Caused by: java.lang.IllegalArgumentException: Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token
at [Source: N/A; line: -1, column: -1] (through reference chain: p4.entities.common.IsoCountry["confirmationResponses"])
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:3605) ~[jackson-databind-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.databind.ObjectMapper.convertValue(ObjectMapper.java:3546) ~[jackson-databind-2.8.9.jar:2.8.9]
at io.leangen.graphql.metadata.strategy.value.jackson.JacksonValueMapper.fromInput(JacksonValueMapper.java:33) ~[spqr-0.9.3.jar:na]
at io.leangen.graphql.metadata.strategy.value.ValueMapper.fromInput(ValueMapper.java:11) ~[spqr-0.9.3.jar:na]
at io.leangen.graphql.generator.mapping.common.InputValueDeserializer.getArgumentValue(InputValueDeserializer.java:19) ~[spqr-0.9.3.jar:na]
at io.leangen.graphql.execution.ResolutionEnvironment.getInputValue(ResolutionEnvironment.java:63) ~[spqr-0.9.3.jar:na]
at io.leangen.graphql.execution.OperationExecutor.execute(OperationExecutor.java:91) ~[spqr-0.9.3.jar:na]
at io.leangen.graphql.execution.OperationExecutor.execute(OperationExecutor.java:59) ~[spqr-0.9.3.jar:na]
... 129 common frames omitted
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.util.LinkedHashMap out of START_ARRAY token
at [Source: N/A; line: -1, column: -1] (through reference chain: p4.entities.common.IsoCountry["confirmationResponses"])
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:270) ~[jackson-databind-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.databind.DeserializationContext.reportMappingException(DeserializationContext.java:1234) ~[jackson-databind-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1122) ~[jackson-databind-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1075) ~[jackson-databind-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.databind.deser.std.StdDeserializer._deserializeFromEmpty(StdDeserializer.java:892) ~[jackson-databind-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:358) ~[jackson-databind-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:27) ~[jackson-databind-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:504) ~[jackson-databind-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:104) ~[jackson-databind-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276) ~[jackson-databind-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140) ~[jackson-databind-2.8.9.jar:2.8.9]
at com.fasterxml.jackson.databind.ObjectMapper._convert(ObjectMapper.java:3600) ~[jackson-databind-2.8.9.jar:2.8.9]
... 136 common frames omitted
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Map Serialization and Deserialization with Jackson - Baeldung
A quick and practical guide to serializing and deserializing Java Maps using Jackson.
Read more >Deserializing into a HashMap of custom objects with jackson
You should create specific Map type and provide it into deserialization process: TypeFactory typeFactory = mapper.
Read more >Map Serialization and Deserialization with Jackson
A process of converting the stream of bytes into a Java object is referred to as deserialization. We can deserialize the JSON data...
Read more >MapDeserializer (jackson-databind 2.8.6 API) - javadoc.io
Basic serializer that can take JSON "Object" structure and construct a Map instance, with typed contents. Note: for untyped content (one indicated by ......
Read more >Jackson - List, Set and Map Serialization and Deserialization ...
In this article, I show you how to use the Jackson API to serialize and deserialize the java collection objects such as List,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe we had the same issue and fixed it by setting:
generator.withScalarMappingStrategy(new MapScalarStrategy());
I solved the this JSON parse issue by replacing “Map<String, String> request” with “Map<String, Object> request”