Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

json · JSON JavaScript Object Notation

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 593
  • Category: Data Formats
  • Founded: Jul 19, 2005
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Messages

Advanced
Messages Help
[question] parse json with ajax   Topic List   < Prev Topic  |  Next Topic >
Summarize Messages Sort by Date  
#842 From: "genzoeri" <genzoeri@...>
Date: Wed Aug 15, 2007 1:48 am
Subject: [question] parse json with ajax
genzoeri
Send Email Send Email
 
Hi,I have difficulties to parse this json
{depth1:{depth2:{depth3:'content'}}}
how to get the 'content'?? using ajax?




#843 From: Crzy4C <Crzy4c@...>
Date: Wed Aug 15, 2007 2:04 am
Subject: Re: [question] parse json with ajax
crzy4c
Send Email Send Email
 
well you don't get "content" using ajax. You get "content" using
javascript...
if that json string was assigned to a variable foo...
var foo = {depth1 : { depth2 : {depth3 : 'content'}}};
and you set...
var foo1 = foo.depth1.depth2.depth3;
then the value of foo1 would be 'content;

Mike

genzoeri wrote:
>
> Hi,I have difficulties to parse this json
> {depth1:{depth2:{depth3:'content'}}}
> how to get the 'content'?? using ajax?
>
>



[Non-text portions of this message have been removed]




#844 From: "Martin Cooper" <mfncooper@...>
Date: Wed Aug 15, 2007 2:11 am
Subject: Re: [question] parse json with ajax
mfncooper
Send Email Send Email
 
On 8/14/07, genzoeri <genzoeri@...> wrote:
>
> Hi,I have difficulties to parse this json
> {depth1:{depth2:{depth3:'content'}}}


That's not valid JSON, for two reasons:

1) Key names are strings, and must be quoted as such.
2) Strings must be quoted with double quotes, not single quotes.

See http://json.org/ for the JSON specification.

--
Martin Cooper


how to get the 'content'?? using ajax?
>
>
>
>
> Yahoo! Groups Links
>
>
>
>


[Non-text portions of this message have been removed]




#845 From: "genzoeri" <genzoeri@...>
Date: Wed Aug 15, 2007 6:34 am
Subject: Re: [question] parse json with ajax
genzoeri
Send Email Send Email
 
I will use this for my AJAX. Using responsetext properties from XHR.
:) ok,then how to parse, {"depth1":{"depth2":{"depth3":"content"}}} ??
btw, thank you for your response. I am glad, I am on the right place.
--- In json@yahoogroups.com, "Martin Cooper" <mfncooper@...> wrote:
>
> On 8/14/07, genzoeri <genzoeri@...> wrote:
> >
> > Hi,I have difficulties to parse this json
> > {depth1:{depth2:{depth3:'content'}}}
>
>
> That's not valid JSON, for two reasons:
>
> 1) Key names are strings, and must be quoted as such.
> 2) Strings must be quoted with double quotes, not single quotes.
>
> See http://json.org/ for the JSON specification.
>
> --
> Martin Cooper
>
>
> how to get the 'content'?? using ajax?
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>
>
> [Non-text portions of this message have been removed]
>





#846 From: Mark Ireland <markincuba@...>
Date: Wed Aug 15, 2007 6:58 am
Subject: RE: [question] parse json with ajax
akaidr4vr
Send Email Send Email
 

Key names must be quoted and cant start with a number?Is that right?To:
json@...: mfncooper@...: Tue, 14 Aug 2007 19:11:32
-0700Subject: Re: [json] [question] parse json with ajax


















On 8/14/07, genzoeri <genzoeri@...> wrote:
>
> Hi,I have difficulties to parse this json
> {depth1:{depth2:{depth3:'content'}}}

That's not valid JSON, for two reasons:

1) Key names are strings, and must be quoted as such.
2) Strings must be quoted with double quotes, not single quotes.

See http://json.org/ for the JSON specification.

--
Martin Cooper

how to get the 'content'?? using ajax?
>
>
>
>
> Yahoo! Groups Links
>
>
>
>

[Non-text portions of this message have been removed]
















_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE

[Non-text portions of this message have been removed]




#847 From: Michal Migurski <mike-jsonphp@...>
Date: Wed Aug 15, 2007 8:09 am
Subject: Re: Re: [question] parse json with ajax
michal_migurski
Send Email Send Email
 
On Aug 14, 2007, at 11:34 PM, genzoeri wrote:
> I will use this for my AJAX. Using responsetext properties from XHR.
> :) ok,then how to parse, {"depth1":{"depth2":{"depth3":"content"}}} ??
> btw, thank you for your response. I am glad, I am on the right place.

This should help:
eval("var responsejson = (" + responsetext + ");");
alert(responsejson['depth1']['depth2']['depth3'];



On Aug 14, 2007, at 11:58 PM, Mark Ireland wrote:
> Key names must be quoted and cant start with a number?Is that right?

Yes.

-mike.

----------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca http://mike.teczno.com/contact.html







#848 From: "Philip Tellis" <philip.tellis@...>
Date: Thu Aug 16, 2007 5:05 am
Subject: Re: Re: [question] parse json with ajax
philiptellis
Send Email Send Email
 
On 15/08/07, Michal Migurski <mike-jsonphp@...> wrote:
>
> This should help:
> eval("var responsejson = (" + responsetext + ");");
> alert(responsejson['depth1']['depth2']['depth3'];

Ugh, don't do that. Apart from screwing with the scope of
responsejson, it also causes a security problem, and it's overkill.
If you must use eval, do it this way:

var responsejson = eval( "(" + o.responseText + ")" );

That won't take away the security problems with eval, but it will make
sure that responsejson is in current scope.



 
Add to My Yahoo!      XML What's This?

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help