This article mainly introduces the php method for implementing json Encoding. The example analyzes the skills related to php's implementation of json encoding conversion, which has some reference value, for more information about how to implement json encoding in php, see the following example. Share it with you for your reference. The details are as follows:
<? Php/** json */$ books = array ('key1' => 'value1', 'key2' => 'value2 ', 'key3' => array ('key4' => 'value4 ', 'key5' => 'value5'); $ json = json_encode ($ books ); $ rejson = json_decode ($ json, true); echo 'original array:
'; Print_r ($ books); echo'
'; Echo' is encoded in json format:
'; Print $ json ."
"; Echo'
'; Echo' after json decoding:
'; Print_r ($ rejson); echo'
'; // Instance $ jsonn =' {"error_code": "400", "request": "\/ Router \/aQConnectError", "api_code": 40006, "error ": "\ Users \ u5165 \ u7684 \ u63a5 \ u53e3 \ u53c2 \ u6570 \ u51fa \ u9519 \ uff0c \ u53c2 \ Users \ u672a \ u8bbe \ u5b9a \ u3002 "}'; print_r (json_decode ($ jsonn);?>
I hope this article will help you with php programming.