Home / PHP Tips Generated By ChatGPT / Working with JSON Data in PHP Encode and decode JSON data for APIs or data storage. Source Code // Encoding to JSON $json = json_encode(['name' => 'John', 'age' => 30]); // Decoding from JSON $data = json_decode($json, true);