JSON from a .js File
I am working on something using JSON and I can't seem to figure out how to do this. I'm receiving a JSON object that looks like this: {"List" : ["ob1":"c1","ob2":开发者_运维技巧"c2"...]}
I am getting this from a .js file. How do I use the object?
So far I've only worked with files that have objects like this: Object = {"List" : ["ob1":"c1","ob2":"c2"...]}
And that's simple to use since all I have to do is import the .js file and then call Object.List [etc].
I'm a little bit of a noob so bear with me on this :( ..
Thanks in advance!
If you mean that you are calling out to a service and it is returning the json back to you like that then you need to do something to get it into an object. Pretty much all of the popular javascript frameworks have a method to wrap this for you, in MooTools you would use Request.JSON instead of a normal request, and then it will parse the response and give you the basic object. If you really want to know the nitty gritty of parsing it out, then the source for MooTools or any of the other javascript frameworks out there would be a great source.
精彩评论