Accessing JSON members

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing JSON members

horrido
I am completely, utterly, and totally confused by JSON. I've read all the docs and I still can't understand what the hell is going on! I must be the densest person on the planet...

I've used JQuery ajax: to POST a JSON request. 

 JQuery current ajax: #{
 
'type' -> 'POST'.
 
'url' -> 'some URL'.
 
'dataType' -> 'json'.
 
'success' -> [:jsonData | '#output-list' asJQuery append: '<br>',(JSON stringify: jsonData)].
 
'error' -> [:xhr :status | alert value: status]
 
}.


On success, the value of jsonData is:

{"verified":false,"id":0}

Based on my understanding of Amber-to-JS mapping and JSON format, the following should give me a value of false:

jsonData verified

But it doesn't.

I've read docs on JSON parse: and JSON stringify:, and jQuery ajax:'s success setting, and the more I read, the more confused I get. How can this JSON stuff be so damn complicated???

I just want to access the value of "verified":false. It can't be that hard, can it?

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Accessing JSON members

horrido
Okay, I must've made some kind of typo early on, because it's working now. 'jsonData verified' is the correct syntax.

<sigh>



On Sunday, 7 June 2015 14:53:42 UTC-4, Richard Eng wrote:
I am completely, utterly, and totally confused by JSON. I've read all the docs and I still can't understand what the hell is going on! I must be the densest person on the planet...

I've used JQuery ajax: to POST a JSON request. 

 JQuery current ajax: #{
 
'type' -> 'POST'.
 
'url' -> 'some URL'.
 
'dataType' -> 'json'.
 
'success' -> [:jsonData | '#output-list' asJQuery append: '<br>',(JSON stringify: jsonData)].
 
'error' -> [:xhr :status | alert value: status]
 
}.


On success, the value of jsonData is:

{"verified":false,"id":0}

Based on my understanding of Amber-to-JS mapping and JSON format, the following should give me a value of false:

jsonData verified

But it doesn't.

I've read docs on JSON parse: and JSON stringify:, and jQuery ajax:'s success setting, and the more I read, the more confused I get. How can this JSON stuff be so damn complicated???

I just want to access the value of "verified":false. It can't be that hard, can it?

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.