I have to wrap some JSON in a response entity in order to pass it. The JSON looks like this:
{"headers":{"Content-Type":["application/json; charset=utf-8"]},"body":"\"[{\\\"name\\\":\\\"BFF\\\",\\\"id\\\":\\\"10713436\\\"}...
If I call $.parseJSON(thatthing.body), I get:
[{"name":"BFF","id":"10713436"},...
which looks good -- like a list of maps, which is what I expect. But If I call $.parseJSON(thatthing.body)[0], I just get the character '[' -- the literal first character of that text.
How do I instead treat this object like the list of maps that it is?
thatthing.bodyis a string that contains a string containing JSON. You have to parse twice. Better: Fix the code that generates this mess."\"[{\\\": It's a string (first"), which contains another string (\") which contains JSON ([{\\\"). Also, since you said that$.parseJSON(thatthing.body)[0]returns[, it means that$.parseJSON(thatthing.body)returns a string.