Json Parse

42 views
Skip to first unread message

swathi jakkam

unread,
Apr 10, 2012, 1:52:42 AM4/10/12
to v8-users
Hi,

I have problem with JSON.parser function in v8.How to use the JSON
methods in V8.Anyone could you tell me the idea about JSON in
javascript.

Issue: Json.parser() function gives wrong output.

i wrote sample example like below:

var foo = {};
foo.bar = "new property";
foo.baz = 3;

var JSONfoo = JSON.stringify(foo);
print(JSONfoo);

//To make JSONfoo back into a JavaScript object just do:
var backToJS = json_parse(JSONfoo);
print(backToJS);

expected result is : {“bar”:”new property”, “baz”:3} // this
is for JSONfoo
{bar:’new property’, baz:
3} // this is for backToJS

But here getting output is wrong
Coming result is : {“bar”:”new property”, “baz”:3} // this
is for JSONfoo
[object
object] // this is for backToJS

Every time I got [object] message for JSON.parser().
I don’t known Why this is coming?


Regards,
swathi

Rico Wind

unread,
Apr 10, 2012, 3:36:59 AM4/10/12
to v8-u...@googlegroups.com
You _are_ getting back an object from JSON.parse!
Try doing:
print(backToJS.bar);
print(backToJS.baz);
To see that it is actually the real values that it contains.

You will see the exact same behavior if you print foo (i.e., you will
see [object])

Cheers,
Rico

> --
> v8-users mailing list
> v8-u...@googlegroups.com
> http://groups.google.com/group/v8-users

swathi jakkam

unread,
Apr 10, 2012, 5:45:27 AM4/10/12
to v8-users
hi,

Thanks for reply.I got the output.

Is there any sample example for javascript JSON. could please suggest
the any good document about this JSON.

Thanks,
swathi.

Rico Wind

unread,
Apr 10, 2012, 6:36:10 AM4/10/12
to v8-u...@googlegroups.com

Stephan Beal

unread,
Apr 10, 2012, 7:28:42 AM4/10/12
to v8-u...@googlegroups.com
On Tue, Apr 10, 2012 at 11:45 AM, swathi jakkam <jakkams...@gmail.com> wrote:
Is there any sample example for javascript JSON. could please suggest
the any good document about this JSON.

--
----- stephan beal
http://wanderinghorse.net/home/stephan/
Reply all
Reply to author
Forward
0 new messages