![](/img/trans.png)
[英]How can i insert decoded json data using json string in php mysql database
[英]Can I insert PHP variables into a JSON string?
我正在使用REST API将属性POST到使用json的人。 我的请求正文如下所示:
$requestBody = '
{
"attribute": {
"@id": "",
"@uri": "",
"person": {
"@id": "222",
"@uri": "https://api_name_removed.com/v1/People/222"
},
"attributeGroup": {
"@id": "",
"@uri": "",
"name": null,
"attribute": {
"@id": "2404",
"@uri": "",
"name": null
}
},
"lastUpdatedDate": null
}
}';
如何将人员ID,人员uri和属性ID更改为已经存储的变量?
$requestBody = '
{
"attribute": {
"@id": "' . $id . '",
"@uri": "' . $uri . '",
"person": {
"@id": "222",
"@uri": "https://api_name_removed.com/v1/People/222"
},
"attributeGroup": {
"@id": "",
"@uri": "",
"name": null,
"attribute": {
"@id": "2404",
"@uri": "",
"name": null
}
},
"lastUpdatedDate": null
}
}';
$requestBody = sprintf('
{
"attribute": {
"@id": "%u",
"@uri": "%s",
"person": {
"@id": "222",
"@uri": "https://api_name_removed.com/v1/People/222"
},
"attributeGroup": {
"@id": "",
"@uri": "",
"name": null,
"attribute": {
"@id": "2404",
"@uri": "",
"name": null
}
},
"lastUpdatedDate": null
}
}', $id, $uri);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.