as3corelib - JSON - Unexpected Encountered

Hey Everyone,

I’ve been scouring Google for an answer to my question and I can’t for the life of me figure it out…

I downloaded the as3corelib to do some JSON decoding, however, I always get this error

Error: Unexpected c encountered
    at com.adobe.serialization.json::JSONTokenizer/parseError()
    at com.adobe.serialization.json::JSONTokenizer/getNextToken()
    at com.adobe.serialization.json::JSONDecoder/nextToken()
    at com.adobe.serialization.json::JSONDecoder/parseObject()
    at com.adobe.serialization.json::JSONDecoder/parseValue()
    at com.adobe.serialization.json::JSONDecoder()
    at com.adobe.serialization.json::JSON$/decode()
    at mtvn.toonimator::Toonimator/_configLoaded()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

I am reading the data from a file called config.dat… which looks like this…

config={
    "actors": [
        "actor1",
        "actor2",
        "actor3"
    ],
 
    "decors": [
        "decor1",
        "decor2",
        "decor3"
    ], 

    "props": [
        "prop1",
        "prop2",
        "prop3"
    ],

    "music": [
        ["song1", "music1"],
        ["song2", "music2"],
        ["song3", "music3"]
    ],
    "intros": [
        "intro1",
        "intro2",
        "intro3",
    ]
}

I’ve tried changing the config= to nothing and I get “Unexpected encountered”. Reading a flickr feed (http://www.flickr.com/services/feeds/photos_public.gne?tags=flex&format=json - as a test) and I get “Unexpected j encountered”

Can someone PLEASE help me out here?

Thanks,

–d

Okay, this is just a shot in the dark for me, but I’ll try it anyway. Is it possible that you have to declare the config object with “var config” or “var config = function(){” before it’ll work? I assume you probably just left that out of the example, but I’ll try it anyway!

config={
    "actors": [
....

Should this be AS code? To my best knowlage it never worked that way in AS…

var obj:Object = {prop:"value"};

I.e. properties’ name shouldn’t be wrapped with quotes.