0

I have a json which I would like to convert to PoJo and back. The format is like:

{
"name": "abc",
"othernames":{"x":"y", "z": 0}
}

Sometimes other instances are like:

{
"name": "abc",
"othernames":[{}]
}

How do I map this to a custom POJO class? I am finding the othernames part which sometimes is a JsonObject and some other times JsonArray a bit tricky.

I tried MyCustomJsonAdapter, but did not get far.

Federico klez Culloca
  • 26,308
  • 17
  • 56
  • 95
Atul
  • 2,673
  • 2
  • 28
  • 34
  • Where do you get this JSON from? Server? If yes, check their JSON schema and see what is mentioned there. If something is different that what is mentioned there, raise an issue with that team. – kiner_shah Apr 11 '23 at 11:06

0 Answers0