Answers for "read json request php"

PHP
1

php access json object

<?php
  // JSON string
  $someJSON = '[{"name":"Jonathan Suh","gender":"male"},{"name":"William Philbin","gender":"male"},{"name":"Allison McKinnery","gender":"female"}]';

  // Convert JSON string to Object
  $someObject = json_decode($someJSON);
  echo $someObject[0]->name; // Access Object data
?>
Posted by: Guest on April-15-2020
-1

php read json request body

//e.g your JSON Req is like this {"UserName":"Ranish","Password":"asdasdasd"}
$jsonReqUrl  = "php://input";
$reqjson = file_get_contents($jsonReqUrl);
$reqjsonDecode = json_decode($reqjson, true);
echo $reqjsonDecode['UserName'];
Posted by: Guest on August-10-2021
0

PHP code to read JSON string on server

$str_json = file_get_contents('php://input');
Posted by: Guest on December-31-2021

Browse Popular Code Answers by Language