I have the following JSON
{
"extras": {
"google.sent_time": 1502027522898,
"custom": "{\"a\":{\"message_data\":\"\",\"message_id\":\"749\",\"message_command\":\"MESSAGE\"},\"i\":\"899ec3dd\"}",
"from": "62572096498",
"alert": "Read More...",
"title": "New message",
"google.message_id": "0:2905559%2ecccafd7ecd"
}
}
Using
var jsonObj:Object = JSON.parse(str);
Gives the error:
SyntaxError: Error #1132: Invalid JSON parse input.
at JSON$/parseCore()
at JSON$/parse()
I do not understand why this is, the JSON is valid.
Additional information,
The solution I have tried and works is as follows, despite the before and after been valid.
var clean:String = str.split("\\").join('');
clean = clean.replace('"custom":"{"a"', '"custom":{"a"');
clean = clean.replace('"}","from"', '"},"from"');
extras.custompart of a JSON into a JSON sub-object. This means the JSON parser fails at recognizing escaped strings. Are you perchance using skyboy's JSON parser? Maybe you should try a different JSON parser in AS3.