FasterXML / jackson-annotations

Core annotations (annotations that only depend on jackson-core) for Jackson data processor
https://github.com/FasterXML/jackson
Apache License 2.0
1.03k stars 330 forks source link

question: inner string field to a object? #144

Closed gMan1990 closed 5 years ago

gMan1990 commented 5 years ago

how: from {"desc":"{\"a\":1}"} to History instance({"desc":{"a":1}}) ? same question: https://stackoverflow.com/questions/43118435/jackson-parse-string-field-as-json

public Class History{

 // what annotation here?
 private Desc desc;
 //get, set method

 public Class Desc{
  private int a;
  //get, set method
 }

}
cowtowncoder commented 5 years ago

This is an issue tracker, not discussion forum. But if I understand question correctly, no, there is no automated way of doing "json in json". You could do setDesc(String str) in which you parse contents, however. Or assign custom deserializer for class Desc, or field "desc" (use @JsonDeserialize(using = MyDeserializer.class)).

Hope this helps.