标签:=== ast json对象 long pre col val str ons
$sui = [ ‘xixixi‘ => ‘suisuisui‘, ‘hahaha‘ => ‘longlonglong‘, ]; $data = json_encode($sui); print_r($data);
JSON 字符串 ===> JSON对象
# 方式一: 通过 eval
var str = ‘{"xixixi":"suisuisui","hahaha":"longlonglong"}‘;
var obj = eval(‘(‘ + str + ‘)‘);
console.log(obj);
# 方式二: JSON.parse(str)
var str = ‘{"xixixi":"suisuisui","hahaha":"longlonglong"}‘;
var obj = JSON.parse(str); //由JSON字符串转换为JSON对象
console.log(obj);
typeof(obj);
JSON 对象 ===> JSON字符串
var last=obj.toJSONString(); //将JSON对象转化为JSON字符
或者
var last=JSON.stringify(obj); //将JSON对象转化为JSON字符
标签:=== ast json对象 long pre col val str ons
原文地址:https://www.cnblogs.com/boundless-sky/p/9037650.html