mikechambers / as3corelib

An ActionScript 3 Library that contains a number of classes and utilities for working with ActionScript? 3. These include classes for MD5 and SHA 1 hashing, Image encoders, and JSON serialization as well as general String, Number and Date APIs.
1.5k stars 451 forks source link

JSONParseError: Unexpected o encountered #115

Open darronschall opened 14 years ago

darronschall commented 14 years ago

Originally filed by varun.1984 on 2009-09-02T18:05:14

What steps will reproduce the problem? 1. 2. 3.

What is the expected output? What do you see instead? bug free

What version of the product are you using? On what operating system? latest,windows

Please provide any additional information below.

darronschall commented 14 years ago

Updated by darron.schall on 2009-09-03T14:11:25

Please attach the JSON string you are trying to decode so we can identify the potential issue. You might also want to try making sure the JSON string is valid by running it through the online validator at: http://www.jsonlint.com/

darronschall commented 14 years ago

Updated by darron.schall on 2009-09-03T14:11:35

Original ticket set status to NeedMoreInfo (we converted to open)

darronschall commented 14 years ago

Updated by mopics25 on 2009-11-20T12:53:09

here's some code that gives this Error :

darronschall commented 14 years ago

Updated by scitronpousty on 2010-01-07T21:56:45

I checked my JSON on jsonlint and it validates and I also get the unexpected o issue. I searched for a word beginning with o that was not escaped properly and cannot find it.

darronschall commented 14 years ago

Updated by scitronpousty on 2010-01-07T22:02:31

Parsing works though if I use this construct instead:

var decoder:JSONDecoder = new JSONDecoder(resultString); var resultObject:Object = (decoder.getValue() as Object); var features:Array = new Array(resultObject["features"]);

darronschall commented 14 years ago

Updated by rahul.schaudhary on 2010-02-09T11:59:20

I have also fallen into same situation. The only difference is that I am getting- Unexpected j error.

I also have validated my JSON string using the tool provided. Do we have some solution to it?

darronschall commented 14 years ago

Updated by ugommirikwe on 2010-04-13T12:34:51

I had the same issue too, but I discovered the problem was that I didn't indicate in the "resultFormat" property of the HTTPService object as "text". I change this property to text and that error went away. Infact you don't have to use the method suggested by scitronpousty; just write your code the normal way: JSON.decode (e.result.toString())..

Hope this helps someone.

darronschall commented 14 years ago

Updated by Benjamin.Lowenstein on 2010-07-09T22:01:36

The workaround in #5 worked well for me for this exact error.

import com.adobe.serialization.json.JSONDecoder;

var decoder:JSONDecoder = new JSONDecoder(myJSONstring); var myJSONobj:Object = (decoder.getValue() as Object);