This is my base object:
class Obj
{
float t;
String data;
int y;
}
json example: {"t": 11.0, "data": "7432", "y": 0 }
I need to parse in java, using Gson, an input like this:
{
"key1":[{"t": 4.0, "data": "saer", "y": 0 },..,{"t": 6.6, "data": "dfs", "y": 4 }],
"key2":[{"t": 33,50, "data": "3r2", "y": 1 },...,{"t": 43.0, "data": "54t", "y": 3 }],
...
}
In PHP i'm using this script:
$decoded = json_decode($_POST['json']);
foreach ($decoded as $key => $single)
{
foreach ($single as $value)
{
// using $key, $value->t,...
}
}
How can I do the same thing in java? I'm confused how retrive the "key" values.
Thanks