I have a JSON arraylist , Need to read data from it using php. I have tried it and failed simply. I will give all in the following
Input data: JSON
{    
    "orderHistory":[
        {
        "product_name": "mike",
        "product_price": 15000,
        "product_id": 5
        },
        {
        "product_name": "tv",
        "product_price": 25000,
        "product_id": 3
        }
    ]
}
PHPcode
// get posted data
$data = json_decode(file_get_contents("php://input"));
while ($row = $data->fetch(PDO::FETCH_ASSOC)){
        extract($row);
echo '{';
        echo '"message": "array added."';
    echo '}';
} 
Error :
<b>Fatal error</b>:  Uncaught Error: Call to undefined method stdClass::fetch() in
 
     
    