How can I quick and easy save a JSON nested with php. What I mean with nested is this:
nested json:
{
"key1":"value",
"key2":"value",
"key3":"value",
"key4":{
"key1":"value",
"key2":"value",
"key3":"value"
},
"key5":{
"key1":"value",
"key2":"value",
"key3":"value"
}
}
json plain in one line (When I just use echo json_encode($array)) :
{"key1":"value","key2":"value","key3":"value","key4":{"key1":"value","key2":"value","key3":"value"},"key5":{"key1":"value","key2":"value","key3":"value"}}
The reason I want this is that the json must be easy readable for humans. When everything is smacked on one line that doesn't help.
为json_encode
使用正确的$options
参数(PHP> = 5.4)
echo json_encode($object, JSON_PRETTY_PRINT);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.