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<?php
2$jsonurl = "https://reqres.in/api/users/2";
3$json = file_get_contents($jsonurl);
4$jsonDecode = json_decode($json, true);
5echo $jsonDecode['data']['email'];
6?>