I have this type of json from api:
[
{
"id": "12",
"name": "elo2",
"status": "ok",
"vulumes": [
{
"id": 17592,
"name": "vol1",
"status": "ok"
}
]
},
{
"id": "13",
"name": "elo",
"status": "ok",
"vulumes": [
{
"id": "17596",
"name": "vol2",
"status": "ok"
}
]
}
]
ID 12 and 13 its shelf, volumes is a part of shelf with id 17592 and 17596
I cannot to parse it with json, i trying to use gson or json, but i can’t understand how to get sime block, for e.g. block with id 12 for parse info about shelf and existing volumes at this shelf.
Can you help me? In other apis i can see named objects vith k/v, but there is nothing.
With Gson, here’s one simple approach you could take. This demonstrates a Java data structure that matches the JSON example, along with how to deserialize and serialize it using Gson.
Since the attributes of the two object types are almost identical, then maybe the intention was that there be only one object type, with a reference to a collection of objects of the same type. Here’s what that would look like.