PHP解析json字符串问题

json_decode($_POST, true)

解析结果为null

<?php

// the following strings are valid JavaScript but not valid JSON

// the name and value must be enclosed in double quotes
// single quotes are not valid 
$bad_json = "{ 'bar': 'baz' }";
json_decode($bad_json); // null

// the name must be enclosed in double quotes
$bad_json = '{ bar: "baz" }';
json_decode($bad_json); // null

// trailing commas are not allowed
$bad_json = '{ bar: "baz", }';
json_decode($bad_json); // null

json_encode 第二个参数

JSON_UNESCAPED_UNICODE(中文不转为unicode ,对应的数字 256)
JSON_UNESCAPED_SLASHES (不转义反斜杠,对应的数字 64)
https://www.laruence.com/2011/10/10/2239.html

posted on 2020-07-15 17:20  aworkstory  阅读(626)  评论(0编辑  收藏  举报

导航