I'm required to use the plain vanilla JSON.parse built into js. This is the xmlhttp.responseText returned from the service that I'm calling with xhr:
"[{\"Id\":1071,\"Title\":\"Scheduled Maintenance\",\"Summary\":\"Site will be unavailable Sunday, August 7th between 9:00AM and 10:00AM MST.\",\"Severity\":\"Informational\",\"ApplicationsImpacted\":[1068],\"IsPubliclyViewable\":true,\"IsDismissable\":true}]"
JSON.parse() does not convert this string into an object. However, JSON.parse() does convert this string into an object if I write my js like this:
JSON.parse(JSON.parse(xmlhttp.responseText))
This seems to be a hack. Can you recommend a cleaner way to convert this string into an object?
It is working fine just remove the extra quotes(") in the beginning and ending of the string.
JSON.parse("[{\"Id\":1071,\"Title\":\"Scheduled Maintenance\",\"Summary\":\"Site will be unavailable Sunday, August 7th between 9:00AM and 10:00AM MST.\",\"Severity\":\"Informational\",\"ApplicationsImpacted\":[1068],\"IsPubliclyViewable\":true,\"IsDismissable\":true}]")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.