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

How to deserialize to arraylist #54

Closed ppamorim closed 9 years ago

ppamorim commented 9 years ago

I need deserialize a string(json) to a arraylist inside a model. Anyone can help me?

cowtowncoder commented 9 years ago

Google for "issue tracker", and its purpose. It is not a general question support forum.

ppamorim commented 9 years ago

Github has a label "Question", and yes it's a question and this should be documented. It's the basic for a library so used...

ppamorim commented 9 years ago

Solved! More educated people ended up helping me, unlike many here...

On first model:

@JsonProperty("property")
@JsonDeserialize(as=ArrayList.class, contentAs=ModelTwo.class)
  private List<ModelTwo> modelsTwo;

On second model:

@JsonCreator
  public ModelTwo(
      @JsonProperty("id") int id,
      @JsonProperty("name") String name) {
    this.id = id;
    this.name = name;
  }
cowtowncoder commented 9 years ago

Ah. I was not aware of such a type. I hope there is a way to remove this, because this is not a good forum for asking questions. I am glad you found a solution to your problem.