How to load string into json object or better say how to decode into json object.
You can use the `json_decode` function in PHP to parse a JSON string into a PHP object or
array. Here's an example:
```php
$json_string = '{"name":"John","age":30,"city":"New York"}';
$data = json_decode($json_string, true);
print_r($data);
```
This will output:
```php
Array
(
[name] => John
[age] => 30
[city] => New York
)
The second argument `true` tells `json_decode` to return an associative array instead of
a stdClass object.
If the JSON string is invalid or not in the correct format, `json_decode` will return
`NULL`.
You can also use `json_last_error_msg()` to get an error message if the decoding fails:
```php
$data = json_decode($json_string, true);
if ($data === NULL) {
echo "Error: " . json_last_error_msg();
}
Note that `json_decode` will throw a warning if the input string is not a valid JSON. You
can suppress this warning by adding an error handler using `set_error_handler`.
Also, you can use `json_encode` function to encode PHP array or object into JSON string:
```php
$data = array('name' => 'John', 'age' => 30);
$json_string = json_encode($data);
echo $json_string;
```
This will output:
```json
{"name":"John","age":30}