My json data looks like this :
{ "amount":550, "items":[ {"item_id":12334, "price": 504}, {"item_id":12335, "price":206} ] }
I want to know how to parse this data in order to fetch each information in separate variable.
In PHP you can use json_decode($myJsonString), while in Android you might look for a third party library, GSON is a good one though
json_decode($myJsonString)
$data = json_decode($json); foreach($data->items as $item) { echo $item->item_id . ' ' . $item->price; }
Create local variable suppose $response;
store your output in $response;
You can fetch price by following code.
foreach ($response->items as $item){
echo $item->price; echo "<br>";
}
In PHP you can use
json_decode($myJsonString)
, while in Android you might look for a third party library, GSON is a good one though