Search code examples
javajsonobjectgsonpojo

Json with different types in fieds to java object


I try convert this json in a java object with Gson. How can to convert the field "Content"? Sometimes is a string and others is a object with two fields.

"content": "TODO List",

or

"content": {
      "one": "one",
       "other": "other"
}

Solution

  • Answer to following question, might help to solves your problem.

    How to handle different data types with same attribute name with Gson?