سؤال

I figure this may be an unconventional way of creating a JSON string. But, I really need to just be able to make it right in "Sequel Pro" like this

enter image description here

I want to be able to just edit it right there like that. But when I receive the string on the client end, then try to use as3 JSON.parse function on it, it gets an error..."SyntaxError: Error #1132: Invalid JSON parse input."

 private function storyTextCallBack(r:Object):void
            {

                        //storyText is an 'Object'
                storyText = JSON.parse(r.text);

            }

But this is how my client is actually getting it, and it's what I think is breaking the JSON.parse function.....

 [\n\t{\n\t\ttext: "hello this is some json test stuff",\n\t\tduration: "5000"\n\t},\n\t{\n\t\ttext: "this is the second line in that json object thing",\n\t\tduration: "3000"\n\t},\n\t{\n\t\ttext: "this is the third and final line in that json object thing",\n\t\tduration: "8000"\n\t}\n]

anyone have any ideas how I can fix this?

هل كانت مفيدة؟

المحلول

The object names in your JSON need to be inside quotes:

"text":"example text"

You can check if you have a valid JSON object with this parser: http://json.parser.online.fr

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top