I
I
iga24102017-02-21 13:40:17
Java
iga2410, 2017-02-21 13:40:17

How to serialize JSON if the field is not known in advance?

The Json comes in like this. The question is, if the name of the array field is not known in advance (it is not constant and will change every time), how can I properly serialize it so that I can access it later?
908986c1569a4faea82fc3cf01f5d734.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
aol-nnov, 2017-02-21
@aol-nnov

I think it's some sort of design flaw. if it is in your power to change something, change it as soon as possible,
for example

"cart": {
  "id": "588xxxxx",
  "items": [
тут содержимое
  ]
}

A
alex maslakoff, 2017-02-21
@teke_teke

is there one for the cart node? save it, and then just do cart.keys[0].

D
davidnum95, 2017-02-21
@davidnum95

if you use GSON, then write a custom deserializer and save to a normal model

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question