$data = array( 'name' => 'John', 'age' => 30, 'city' => 'New York' ); $json = json_encode($data); echo $json;
{"name":"John","age":30,"city":"New York"}The raw2json function is part of the PHP standard library, which means that it is included in the core PHP code and does not require any external packages or libraries. To use the function, simply call the json_encode() function and pass in the raw data that you want to convert to JSON format.