我已将输出格式化为
{"main" : { "membersdetails": [{result:SMS message(s) sent},
{result:SMS message(s) sent},{result:SMS message(s) sent}]}}
错误是:{结果:SMSmessage(s ---------------------- ^期待 ' STRING',}'
应该怎样做才能使其正确。
答案 0 :(得分:0)
你最好的选择是不手工生成JSON字符串。相反,让json_encode
为您完成:
示例:(live copy)
$data = array(
main => array(
membersdetails => array(
array(
result => 'SMS message(s) sent'
),
array(
result => 'SMS message(s) sent'
),
array(
result => 'SMS message(s) sent'
)
)
)
);
echo json_encode($data);
输出:
{"main":{"membersdetails":[{"result":"SMS message(s) sent"},{"result":"SMS message(s) sent"},{"result":"SMS message(s) sent"}]}}