Json - Java Object to Json

后端 未结 6 434
忘了有多久
忘了有多久 2020-12-10 17:43

I am very new to Json and my goal to create the Json output below from Java bean. How should I structure my Java object? Should I have MyResult class and User and Result as

6条回答
  •  时光取名叫无心
    2020-12-10 18:18

    Although closed, this SO post can help you understand the differences between Jackson and GSON. Which one is "best" depends on what is important for you.

    EDIT: Specifically for Jackson, your example looks a lot like the example they give for what they call Full Data Binding, you can read it here. Btw, although the announced 5 minutes needed to read that document is maybe a bit short, it gives a complete overview of the different ways Jackson can be used. You'll also notice that the examples given do not use annotations.

提交回复
热议问题