1//e.g your JSON Req is like this {"UserName":"Ranish","Password":"asdasdasd"}
2$jsonReqUrl = "php://input";
3$reqjson = file_get_contents($jsonReqUrl);
4$reqjsonDecode = json_decode($reqjson, true);
5echo $reqjsonDecode['UserName'];
1header('Content-Type: application/json');
2
3$colors = array("red","blue","green");
4echo json_encode($colors);
1$json = '
2{
3 "type": "donut",
4 "name": "Cake",
5 "toppings": [
6 { "id": "5002", "type": "Glazed" },
7 { "id": "5006", "type": "Chocolate with Sprinkles" },
8 { "id": "5004", "type": "Maple" }
9 ]
10}';
11
12$yummy = json_decode($json);
13
14print_r($yummy);
15