我有一個返回JSON有效載荷如下逃逸JSON有效載荷與反斜槓
{
"GetIPAResult": "{\"Data\":[{\"Name\":\"Pan1\",\"Email\":\"[email protected]\"},{\"Name\":\"Pan2\",\"Email\":\"[email protected]\"}]}"
}
我怎麼能逃避反斜槓外部服務?我需要使用json路徑,目前我無法做到這一點。有沒有比字符串替換更好的方法?謝謝。
問候, 哈日
我有一個返回JSON有效載荷如下逃逸JSON有效載荷與反斜槓
{
"GetIPAResult": "{\"Data\":[{\"Name\":\"Pan1\",\"Email\":\"[email protected]\"},{\"Name\":\"Pan2\",\"Email\":\"[email protected]\"}]}"
}
我怎麼能逃避反斜槓外部服務?我需要使用json路徑,目前我無法做到這一點。有沒有比字符串替換更好的方法?謝謝。
問候, 哈日
只需簡單地解析您的JSON字符串。像那樣。
var response = {
"GetIPAResult": "{\"Data\":[{\"Name\":\"Pan1\",\"Email\":\"[email protected]\"},{\"Name\":\"Pan2\",\"Email\":\"[email protected]\"}]}"
};
var result = $.parseJSON(response.GetIPAResult);
現在你可以不回斜線讓你的數據(結果變量)。
哈日..在那一刻你的JSON結構如下所示
{"key": "value"}
其中value爲{ 「數據」:JSONARRAY}的字符串化
這裏2例出現..
案例1: 嘗試返回JSON的結構改變爲
{"key": JSONOBJECT} where JSONOBJECT -> {"DATA": JSONARRAY}
案例2:
嘗試返回JSON 「 {與{,\」 轉換爲
{"key": JSONOBJECT} where JSONOBJECT -> {"DATA": JSONARRAY}
通過更換與「和}」與}
因此的
{
"GetIPAResult": "{\"Data\":[{\"Name\":\"Pan1\",\"Email\":\"[email protected]\"},{\"Name\":\"Pan2\",\"Email\":\"[email protected]\"}]}"
}
到
{
"GetIPAResult": {"Data":[{"Name":"Pan1","Email":"[email protected]"},{"Name":"Pan2","Email":"[email protected]"}]}
}
感謝的Sohel結果。我們使用Mule和mule使用Rhinoscript。 Neverthless我插入這個,但得到如下錯誤異常堆棧是: 1.語法錯誤:意外的標記:u(<未知的源代碼>#5)(sun.org.mozilla.javascript.internal.EcmaError) sun.org。 mozilla.javascript.internal.ScriptRuntime:3770(null) – hpandalai