myJSONtext = {user: {errorFirstName:"", errorLastName:"",
errorEmail:"The email address you entered is not valid." } };
But when i try to fetch the values it gives an error as
invalidLabel.. not sure why this is happening?
Value is fetched as myJSONtext.user.errorFirstName.
Also i tried creating an array as in the example on http://
www.json.org/js.html
But still it gives myJSONtext.user has no properties.
On 6/12/06, Ashwin Prabhu <aprabhu1@...> wrote:
>
> Hi,
>
> My JSON text looks as below:
>
> myJSONtext = {user: {errorFirstName:"", errorLastName:"",
> errorEmail:"The email address you entered is not valid." } };
>
> But when i try to fetch the values it gives an error as
> invalidLabel.. not sure why this is happening?
It works fine for me in Firebug. You didn't provide any surrounding code,
but are you sure myJSONtext is still in scope when you're trying to access
it?
--
Martin Cooper
Value is fetched as myJSONtext.user.errorFirstName.
>
> Also i tried creating an array as in the example on http://
> www.json.org/js.html
>
> But still it gives myJSONtext.user has no properties.
>
> Any hint what am i doing wrong.
>
> - Ashwin
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
[Non-text portions of this message have been removed]
This is javascript code, not JSON. Keys should have surrounding quotes
in JSON.
{"user": {"errorFirstName":"", "errorLastName::"", "errorEmail":"The
email address you entered is not valid." } }
/Henrik Hjelte
On mån, 2006-06-12 at 22:39 +0000, Ashwin Prabhu wrote:
> Hi,
>
> My JSON text looks as below:
>
> myJSONtext = {user: {errorFirstName:"", errorLastName:"",
> errorEmail:"The email address you entered is not valid." } };
>
> But when i try to fetch the values it gives an error as
> invalidLabel.. not sure why this is happening?
> Value is fetched as myJSONtext.user.errorFirstName.
>
> Also i tried creating an array as in the example on http://
> www.json.org/js.html
>
> But still it gives myJSONtext.user has no properties.
>
> Any hint what am i doing wrong.
>
> - Ashwin
>
>
>
>
>
Thanks very much for your response.
Without quotes its working for me.
With quotes FireFox is throwing an error as 'invalidLabel', when the
'eval' method is called.
Things are working now :)
- Ashwin
On Jun 13, 2006, at 9:31 AM, henrik hjelte wrote:
> This is javascript code, not JSON. Keys should have surrounding quotes
> in JSON.
>
> {"user": {"errorFirstName":"", "errorLastName::"", "errorEmail":"The
> email address you entered is not valid." } }
>
> /Henrik Hjelte
>
> On mån, 2006-06-12 at 22:39 +0000, Ashwin Prabhu wrote:
>> Hi,
>>
>> My JSON text looks as below:
>>
>> myJSONtext = {user: {errorFirstName:"", errorLastName:"",
>> errorEmail:"The email address you entered is not valid." } };
>>
>> But when i try to fetch the values it gives an error as
>> invalidLabel.. not sure why this is happening?
>> Value is fetched as myJSONtext.user.errorFirstName.
>>
>> Also i tried creating an array as in the example on http://
>> www.json.org/js.html
>>
>> But still it gives myJSONtext.user has no properties.
>>
>> Any hint what am i doing wrong.
>>
>> - Ashwin
>>
>>
>>
>>
>>
>
>
>
> ------------------------ Yahoo! Groups Sponsor --------------------
> ~-->
> Home is just a click away. Make Yahoo! your home page now.
> http://us.click.yahoo.com/DHchtC/3FxNAA/yQLSAA/1U_rlB/TM
> --------------------------------------------------------------------
> ~->
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
My understanding of JSON was that you need to form a Text in such way
that, when we create a JSON object using 'eval', then we can
traverse its properties using aJSONObject.attributeName.
So instead of returning XML and parsing it (which i have done before
in javascript ), i am returning this text and then converting it
into a JSON object.
Am i thinking wrong! Please correct me.
Thanks.
- Ashwin
On Jun 13, 2006, at 9:02 PM, Douglas Crockford wrote:
>> With quotes FireFox is throwing an error as 'invalidLabel', when the
>> 'eval' method is called.
>
> Why are you using eval?
>
>
>
>
>
> ------------------------ Yahoo! Groups Sponsor --------------------
> ~-->
> You can search right from your browser? It's easy and it's free.
> See how.
> http://us.click.yahoo.com/_7bhrC/NGxNAA/yQLSAA/1U_rlB/TM
> --------------------------------------------------------------------
> ~->
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
This confusion came up because in the sample code you provided:
> myJSONtext = {user: {errorFirstName:"", errorLastName:"",
> errorEmail:"The email address you entered is not valid." } };
You directly have Javascript statement for object and there was no
need for 'eval'ing it. That was Doug's point.
Pavan Keely
--- In json@yahoogroups.com, "Matthew Morley" <WickedLogic@...> wrote:
>
> Perhaps he is asking why you aren't using:
>
> http://json.org/json.js
> -----------------------------------------------------
> string.parseJSON()
>
> This method parses a JSON text to produce an object or
> array. It will return false if there is an error.
> --
> Matt (MPCM)
>
Thanks very much for all the clarifications. i think, i know what i
was doing wrong.
As for parseJSON, yup i will using that.
Thanks again!
- Ashwin
On Jun 15, 2006, at 12:08 PM, keelypavan wrote:
> Ashwin,
>
> This confusion came up because in the sample code you provided:
>
>> myJSONtext = {user: {errorFirstName:"", errorLastName:"",
>> errorEmail:"The email address you entered is not valid." } };
>
> You directly have Javascript statement for object and there was no
> need for 'eval'ing it. That was Doug's point.
>
> Pavan Keely
>
> --- In json@yahoogroups.com, "Matthew Morley" <WickedLogic@...> wrote:
>>
>> Perhaps he is asking why you aren't using:
>>
>> http://json.org/json.js
>> -----------------------------------------------------
>> string.parseJSON()
>>
>> This method parses a JSON text to produce an object or
>> array. It will return false if there is an error.
>> --
>> Matt (MPCM)
>>
>
>
>
>
>
>
>
> ------------------------ Yahoo! Groups Sponsor --------------------
> ~-->
> Great things are happening at Yahoo! Groups. See the new email
> design.
> http://us.click.yahoo.com/TISQkA/hOaOAA/yQLSAA/1U_rlB/TM
> --------------------------------------------------------------------
> ~->
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
> My understanding of JSON was that you need to form a Text in such way
> that, when we create a JSON object using 'eval', then we can
> traverse its properties using aJSONObject.attributeName.
> So instead of returning XML and parsing it (which i have done before
> in javascript ), i am returning this text and then converting it
> into a JSON object.
> Am i thinking wrong! Please correct me.
It would be helpful to have some more context; the first snippet you
sent was just plain old Javascript, and didn't show how you're using
eval().
-mike.
------------------------------------------------------
michal migurski- contact info, blog, and pgp key:
sf/ca http://mike.teczno.com/contact.html
It sounds like either your eval() statement is incorrect or your JSON string
is malformatted.
Below is a simple example of some JSON written in JavaScript that I know
will work in Firefox.
var JSONstr = '{keyOne:"Alpha",keyTwo:"Omega"}';
var JSONvar = eval('('+JSONstr+')');
alert(JSONvar.keyOne);
This should work if you replace the JSONstr variable I'm setting here with a
JSON string dynamically built on the server and passed in.
HTH,
-Todd
On 6/15/06, Ashwin Prabhu <aprabhu1@...> wrote:
>
> Hi Doug,
>
> My understanding of JSON was that you need to form a Text in such way
> that, when we create a JSON object using 'eval', then we can
> traverse its properties using aJSONObject.attributeName.
> So instead of returning XML and parsing it (which i have done before
> in javascript ), i am returning this text and then converting it
> into a JSON object.
> Am i thinking wrong! Please correct me.
>
> Thanks.
>
> - Ashwin
>
> On Jun 13, 2006, at 9:02 PM, Douglas Crockford wrote:
>
> >> With quotes FireFox is throwing an error as 'invalidLabel', when the
> >> 'eval' method is called.
> >
> > Why are you using eval?
> >
> >
> >
> >
> >
> > ------------------------ Yahoo! Groups Sponsor --------------------
> > ~-->
> > You can search right from your browser? It's easy and it's free.
> > See how.
> > http://us.click.yahoo.com/_7bhrC/NGxNAA/yQLSAA/1U_rlB/TM
> > ----------------------------------------------------------
> > ~->
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>
>
>
[Non-text portions of this message have been removed]