2016-03-10 36 views
-1

這是我現在有:如何將JSON字符串轉換爲帶有Javascript字段的對象?

console.log(JSON.stringify(errorParam)) 
{"data":{"message":"{\"ErrorLine\":113,\"ErrorMessage\":\"Authentication Failed\",\"ErrorNumber\":50004,\"ErrorProcedure\":\"start_test\"}"},"status":400,"statusText":"Bad Request"} 

我知道JSON.stringify但我怎麼能轉換這個回對象從一個字符串?

+1

'JSON.parse()來'是你所需要的。 – Adam

+0

只需使用JSON.Parse(errorParam) – ani0904071

+0

JavaScript對象不具有「字段」。他們有「財產」。 –

回答

2

我知道JSON.stringify,但我怎麼能轉換回到 對象從字符串?

使用JSON.parse

console.log(JSON.parse('{"data":{"message":"{\"ErrorLine\":113,\"ErrorMessage\":\"Authentication Failed\",\"ErrorNumber\":50004,\"ErrorProcedure\":\"start_test\"}"},"status":400,"statusText":"Bad Request"}')); 
相關問題