解析問題,JSON從我有以下保存在輸入隱藏字段JSON字符串隱藏的文本字段
[{"pro":{"draft":{"create":"1"},"submitted":{"edit":"1","delete":"0"}},"ind":{"draft":{"create":""},"submitted":{"edit":"","delete":""}}}]
當我正在嘗試從隱藏的文本字段像JSON,
JSON.stringify($('#SecurityJSON').val()) //returns "[{"
但是,如果嘗試直接傳遞字段內容爲JSON字符串化然後返回適當的JSON,
JSON.stringify([{"pro":{"draft":{"create":"1"},"submitted":{"edit":"1","delete":"0"}},"ind":{"draft":{"create":""},"submitted":{"edit":"","delete":""}}}]) //works well
我需要解析/格式化文本字段以檢索正確的JSON?
你有沒有正確轉義輸入的'「'價值呢? –
感謝您指出,這是問題了。 – Rishi