$json = '{"name": "John", "age": 30}'; $obj = json_decode($json); $name = $obj->name; // Retrieve the string value of "name" echo $name; // Output: John
$json = '["apple", "banana", "orange"]'; $arr = json_decode($json); $fruit = $arr[1]; // Retrieve the string value of the second element (index 1) echo $fruit; // Output: bananaThe JSON getString function is not a standard PHP function, but it may be included in certain package libraries such as the "JsonSerializable" interface in the PHP Standard Library.