2016-03-10 35 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"}')); 
相关问题