I am trying to get a json(has unknown template) value with a dynamic key like;
"user.specs.id"
Problem is my json structure is not static and because of this I can't parse it to a java Object or get its properties with Gson methods.
{
"user": {
"specs": {
"id": 12222,
"name": "foo"
}
}
}
Is there a way to extract some data from any json with some key?
EDIT: I have a service method like;
public Object getValueByKey(String json, String key);
possible values for "json" param;
{"name": "test"} //possible key "name"
{"user": {"id": 1232}} //possible key "user.id"
{"cars": ["car1", "car2"]} //possible key "cars[0]"