This article mainly introduces the PHP implementation of JSON coding method, example of PHP to implement the JSON encoding conversion of the relevant skills, with a certain reference value, the need for friends can refer to the following
In this paper, we explain how to implement JSON encoding in PHP. Share to everyone for your reference. Specific 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:<br/> ';p rint_r ($ Books, Echo ' <br/><br/> ', echo ':<br/> ';p rint $json after JSON encoding. <br/> "; Echo ' <br/> '; Echo ' after JSON decoded:<br/> ';p rint_r ($rejson); Echo ' <br/><br/> ';//instance $ Jsonn = ' {' Error_code ': ' + ', ' request ': ' \/router\/aqconnecterror ', ' api_code ': 40006, ' error ': ' \u4f20\u5165\u7684\ u63a5\u53e3\u53c2\u6570\u51fa\u9519\uff0c\u53c2\u6570openid\u672a\u8bbe\u5b9a\u3002 "} ';p Rint_r (Json_decode ($ Jsonn));? >