You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm new in LoganSquare, and i'm faced with next problem.
I have next json structure:
{
"status": "ok", -> String
"meta": { -> Model with integer value
"count": 1
},
"data": { -> Model with child JSON object
"1466466": { <------ Dynamic name
"field1": "value1",
"field2": value2,
"field3": value3
}
}
}, where "1466466" is filed with dynamic key. How I can parse it?
Thanks.
The text was updated successfully, but these errors were encountered:
My initial reaction to this situation would be to map your data field to a Map<String, Fields> object, where Fields is a @JsonObject class containing your field1 to field3 stuff. Then, you'd expose some more convenient accessors to those fields based on the keySet() of that Map:
@JsonObjectclassOuter {
@JsonField(name = "status")
Stringstatus;
@JsonField(name = "meta")
Metameta;
@JsonField(name = "data")
Map<String, Fields> data;
// ...publicStringgetField1() {
// Of course, you probably want to check for "empty" first, this is just the basic ideareturndata.keySet().get(0).getField1();
}
}
@JsonObjectclassFields {
@JsonField(name = "field1")
Stringfield1;
// ...
}
Hello everybody.
I'm new in LoganSquare, and i'm faced with next problem.
I have next json structure:
{
"status": "ok", -> String
"meta": { -> Model with integer value
"count": 1
},
"data": { -> Model with child JSON object
"1466466": { <------ Dynamic name
"field1": "value1",
"field2": value2,
"field3": value3
}
}
}, where "1466466" is filed with dynamic key. How I can parse it?
Thanks.
The text was updated successfully, but these errors were encountered: