PHP - это json string
function IsJsonString(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
Joyous Jaguar
function IsJsonString(str) {
try {
JSON.parse(str);
} catch (e) {
return false;
}
return true;
}
<?php
$jsonurl = "https://reqres.in/api/users?page=2";
$json = file_get_contents($jsonurl);
$jsonDecode = json_decode($json, true);
var_dump($jsonDecode['data']);
foreach($jsonDecode['data'] as $mydata){
echo $mydata['email'] . "<br>";
}
?>
$data = json_decode($json);
$json = '
{
"type": "donut",
"name": "Cake",
"toppings": [
{ "id": "5002", "type": "Glazed" },
{ "id": "5006", "type": "Chocolate with Sprinkles" },
{ "id": "5004", "type": "Maple" }
]
}';
$yummy = json_decode($json, true);
echo $yummy['toppings'][2]['type']; //Maple
//code igniter
$query="qry";
$query = $this->db->query($query);
$res=$query->result();
return json_encode($res);