【发布时间】:2020-07-14 06:58:50
【问题描述】:
我正在努力编码 json 数据
当发布到 confluenec 时,它需要是
{"id":"282072112","type":"page","title":"new page","space":{"key":"BLA"},"body":{"storage":{"value":"<p>This is the updated text for the new page</p>","representation":"storage"}},"version":{"number":2}}'
所以在我创建的 php 中
$data = array('id'=>$siteid, 'type'=>'page', 'title'=>'title of the page');
$data_json = json_encode($data);
print_r ($data_json);
最终结果应该是这样的
{
"id": "282072112",
"type": "page",
"title": "new page",
"space": {
"key": "BLA"
},
"body": {
"storage": {
"value": "<p>This is the updated text for the new page</p>",
"representation": "storage"
}
},
"version": {
"number": 2
}
}
但我怎样才能添加孩子等?
谢谢
【问题讨论】:
-
你可以尝试
json_decode( $json, true);你的目标字符串,然后print_r()结果看看数组是如何嵌套的。
标签: php