我想用php
生成这个JSON数组select
max(case when AccountCode = 1000 then case when TransactionType = 'Debit' then Amount end else case when AccountCode = 1000 then case when TransactionType = 'Credit' then Amount*-1 end) [Total Transaction Premium]
max(case when AccountCode = 1000 then case when TransactionType = 'Debit' then Amount end else case when AccountCode = 1000 then case when TransactionType = 'Credit' then Amount*-1 end) [Total Transaction Premium]
from PolicyTransactionSplits
where PolicyTransactionId = 10
但如果我使用此代码:
{"to": "/topics/foo-bar"}
它正在返回
{“to”:“/ topics / foo-bar”}
我尝试了$topic = "/topics/foo-bar";
$g_topic= array(
'to' => $topic
);
echo json_encode($g_topic );
,stripslashes()
,但没有一种方法可以使用
答案 0 :(得分:0)
就在the manual for the json_encode() function:
echo json_encode($g_topic, JSON_UNESCAPED_SLASHES);
将产生:
{"to": "/topics/foo-bar"}
答案 1 :(得分:0)
你需要像这样回应它。
$topic = "/topics/foo-bar";
$g_topic= array(
'to' => $topic
);
echo json_encode($g_topic, JSON_UNESCAPED_SLASHES), "\n";