Using JSON

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Using JSON

Post by daedalus__ »

I've been looking at JSON alot lately.

I just want to take a simple JSON thing:

Code: Select all

var json_obj = {
var:"blah",
var:"blah",
func1: function() {
/* stuff */
},
func2:function() {
/*stuff*/
}
}
and then turn it into an object:

Code: Select all

obj_name = new json_obj();
I found one thing that is susposed to help called json.js but I couldn't get it to work.

:(
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

sn't it already an object itself?
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

Yes but I want to be able to make copies of it or at least reference it.
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

JSON is (afaik) used to facilitate the transfer of javascript "items" (objects, arrays, etc) from place to place, i.e. client side to almost any server side language. if you're staying within js, you dont really need json for anything, it's when you want to send (or retrieve, ala google maps geocoder) data.

Or are you trying to take a preformatted json string and convert it into it's javascript form...
User avatar
daedalus__
DevNet Resident
Posts: 1925
Joined: Thu Feb 09, 2006 4:52 pm

Post by daedalus__ »

I like JSON because it is beautiful. I read earlier today that JSON objects can only be singletons though I found a little script that will let you turn them into classes; That is what i was looking for in the first place.

It is called Classy JSON.
Post Reply