大家好,又见面了,我是你们的朋友全栈君。
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
//解析为json对象
var_dump(json_decode($json));
//解析为数组
var_dump(json_decode($json, true));
代码执行结果
object(stdClass)#1 (5) {
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
}
array(5) {
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
}
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/160656.html原文链接:https://javaforall.cn