Handling JSON Invalidity in PHP
It happens that a string with JSON
is built incorrectly. In this
case, the json_decode function
will return null. Let's
try it in practice.
Let's make invalid JSON (determine
for yourself what's wrong with it):
php<?php
$json = '["a", "b", "c",]';
?>
Let's try to parse this JSON:
php<?php
$data = json_decode($json);
var_dump($data); // will output null
?>
Задание 1
Given a string with some JSON. Parse it into a PHP data structure. Output the parsing result or an error if parsing the JSON failed.