Re: [jackson-user] JsonMappingException with jackson-databind version 2.8.0 and higher

2017-03-23 Thread Tatu Saloranta
Could you please file an issue for `jackson-databind`. Looks like a bug.

-+ Tatu +-

On Thu, Mar 23, 2017 at 5:11 PM, Anuj Kumar  wrote:
>
> I am getting an exception with jackson databind version 2.8.0 and later,
> everything works fine with any version below 2.8.0.
>
> Issue is, if I have a property name with an underscore and the letter after
> it is NOT the same as the first letter, then things blow up.
>
>
> For example I have a Person class which contains a Set which has the
> name as "person_z" which fails.
>
> But if I rename it to "person_p" it works.
>
>
> public class Person {
> @JsonProperty("name")
> private String name;
> @JsonProperty("person_z") // renaming this to person_p works
> @JsonIgnoreProperties(value = {"person_z"}) // renaming this to person_p
> works
> private Set personZ;
> }
>
>
> public class TestJackson {
>
> public static void main(String[] args) throws IOException {
>
> String st =" [ {\n"
> + "\"name\": \"admin\",\n"
> + "\"person_z\": [" // renaming this to person_p works
> + "  {"
> + "\"name\": \"admin\""
> + "  }"
> + "]"
> + "  }]";
>
> ObjectMapper mapper = new ObjectMapper();
> mapper.readValue(st,
> mapper.getTypeFactory().constructCollectionType(List.class, Person.class));
> }
>
> }
>
>
> Exception in thread "main"
> com.fasterxml.jackson.databind.JsonMappingException: No _valueDeserializer
> assigned
>  at [Source:  [ {
> "name": "admin",
> "person_z": [  {"name": "admin"  }]  }]; line: 3,
> column: 41] (through reference chain:
> java.util.ArrayList[0]->com.example.Person["person_z"]->java.util.HashSet[0]->com.example.Person["name"])
>   at
> com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:261)
>   at
> com.fasterxml.jackson.databind.DeserializationContext.reportMappingException(DeserializationContext.java:1233)
>   at
> com.fasterxml.jackson.databind.deser.impl.FailingDeserializer.deserialize(FailingDeserializer.java:27)
>   at
> com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:490)
>   at
> com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:101)
>   at
> com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276)
>   at
> com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
>   at
> com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:277)
>   at
> com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:249)
>   at
> com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)
>   at
> com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:490)
>   at
> com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:101)
>   at
> com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276)
>   at
> com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
>   at
> com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:277)
>   at
> com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:249)
>   at
> com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)
>   at
> com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3789)
>   at
> com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2871)
>   at com.example.TestJackson.main(TestJackson.java:28)
>   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>   at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>   at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>   at java.lang.reflect.Method.invoke(Method.java:498)
>   at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
>
> --
> You received this message because you are subscribed to the Google Groups
> "jackson-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jackson-user+unsubscr...@googlegroups.com.
> To post to this group, send email to jackson-user@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jackson-

[jackson-user] JsonMappingException with jackson-databind version 2.8.0 and higher

2017-03-23 Thread Anuj Kumar



I am getting an exception with jackson databind version 2.8.0 and later, 
everything works fine with any version below 2.8.0. 

Issue is, if I have a property name with an underscore and the letter after it 
is NOT the same as the first letter, then things blow up.


For example I have a Person class which contains a Set which has the 
name as "person_z" which fails. 

But if I rename it to "person_p" it works.


public class Person {
@JsonProperty("name")
private String name;
@JsonProperty("person_z") // renaming this to person_p works
@JsonIgnoreProperties(value = {"person_z"}) // renaming this to person_p 
works
private Set personZ;
}


public class TestJackson {

public static void main(String[] args) throws IOException {

String st =" [ {\n"
+ "\"name\": \"admin\",\n"
+ "\"person_z\": [" // renaming this to person_p works
+ "  {"
+ "\"name\": \"admin\""
+ "  }"
+ "]"
+ "  }]";

ObjectMapper mapper = new ObjectMapper();
mapper.readValue(st, 
mapper.getTypeFactory().constructCollectionType(List.class, Person.class));
}

}


Exception in thread "main" com.fasterxml.jackson.databind.JsonMappingException: 
No _valueDeserializer assigned
 at [Source:  [ {
"name": "admin",
"person_z": [  {"name": "admin"  }]  }]; line: 3, 
column: 41] (through reference chain: 
java.util.ArrayList[0]->com.example.Person["person_z"]->java.util.HashSet[0]->com.example.Person["name"])
at 
com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:261)
at 
com.fasterxml.jackson.databind.DeserializationContext.reportMappingException(DeserializationContext.java:1233)
at 
com.fasterxml.jackson.databind.deser.impl.FailingDeserializer.deserialize(FailingDeserializer.java:27)
at 
com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:490)
at 
com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:101)
at 
com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276)
at 
com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
at 
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:277)
at 
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:249)
at 
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)
at 
com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:490)
at 
com.fasterxml.jackson.databind.deser.impl.FieldProperty.deserializeAndSet(FieldProperty.java:101)
at 
com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:276)
at 
com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:140)
at 
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:277)
at 
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:249)
at 
com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)
at 
com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3789)
at 
com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2871)
at com.example.TestJackson.main(TestJackson.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jackson-user+unsubscr...@googlegroups.com.
To post to this group, send email to jackson-user@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.