2013-03-17 39 views
0

JSON顯然看起來很喜歡這個。JSON數組不會解碼?

{\"amount\":10,\"conversion_id\":\"5145fd4e04af9\",\"extra_params\": 
    {\"ip\":\"99.237.185.67\",\"user_agent\":\"Mozilla/5.0 (Windows NT 6.1; WOW64) 
    AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 
    Safari/537.11\"},\"job_title\":\"Answer a few questions about a website (Canada - 
    Sunday task #1) (Canada Only)\",\"adjusted_amount\":8.0} 

但json_decode在php中不起作用。幫幫我???

+4

的JSON是無效的。鍵必須是字符串,即用雙引號。解決這個問題,'json_decode'將會工作。 – 2013-03-17 17:25:32

+0

您可以使用http://www.jslint.com/來驗證您的json。它應該是{ 「有效載荷」:{ 「conversion_id」:「32402345984532934511」, 「金額」:50, 「adjusted_amount」 :25, 「JOB_TITLE」: 「在過去的工作中,他們完成了標題(和其他2個作業)」 }, 「簽名」: 「1221299611f823b8c30a347373b449ad」 } – PSL 2013-03-17 17:28:49

+0

這也是無效與 – 2013-03-17 17:43:28

回答

3

這不是有效的JSON。在JSON密鑰必須與"被引用,所以你的東西,JSON將

{ 
    "payload": { 
     "conversion_id": "32402345984532934511", 
     "amount": 50, 
     "adjusted_amount": 25, 
     "job_title": "The title of the last job they completed (and 2 other jobs)" 
    }, 
    "signature": "1221299611f823b8c30a347373b449ad" 
} 

另見http://json.org

+0

另外,你'\「'。可能需要查看RFC 4627(請參閱:http://www.ietf.org/rfc/rfc4627.txt)。這是指定JSON格式的地方。儘管許多實現允許非字符串格式化鍵作爲保存某些輸入的快捷方式不符合標準。 – mikyra 2013-03-17 17:31:02