Get value of JSON

Mike Bonner bonnmike at gmail.com
Fri Aug 5 10:33:58 EDT 2016


While i'm not yet good at reading json directly, i'm guessing mergeJson
works similarly to the built in json library, so I shoved your first sample
into a field and did the following in the message box.

put jsonimport(field 1) into tdat; put the keys of  tdat
>From that first example, it looks like total_count is a toplevel key, but
that may differ based on your later email.. I'm not sure how the two pieces
fit together though, so no clue where your keys will actually end up.
Having said that..
Once its imported into an array, it should be easy enough to dig around
(put the keys..) and figure out where things are.
putting the keys of yourarray["entries"] returns a 1 (only 1 entry) but its
obvious that there will be a numeric key for each entry.  Then checking the
keys of yourarray["entries"][1] returns the following keys..

transaction_type
5
is_read
date_created
source_url
1.6
transaction_id
3
2
user_agent
is_starred
payment_amount
payment_status
status
ip
currency
created_by
post_id
form_id
is_fulfilled
payment_method
payment_date
id
4
1.3
6

Again, this is from the first sample you posted, things may differ once you
use data with all levels of depth, but it shouldn't be too bad to just dig
through and locate the keys you need with the message box.

On Fri, Aug 5, 2016 at 8:16 AM, Skip Kimpel <skiplondon at gmail.com> wrote:

> Further correction (sorry!) There were some more levels to the JSON file...
> Still trying to get the total_count value as well value from item 1/2 which
> is the email address:
>
>
> {"status":200,"response":{"entries":[{"1.6":"LName","transaction_id":null,"6":"","payment_date":null,"4":"This
> is just a
>
> test","post_id":null,"id":1,"is_read":1,"is_fulfilled":null,"form_id":2,"status":"active","payment_method":null,"is_starred":0,"transaction_type":null,"created_by":null,"source_url":"
> http://te.com
>
> ","payment_status":null,"1.3":"FName","3":"(555)222-5555","payment_amount":null,"ip":"71.229.127.176","2":"
> g at test.com","5":"","currency":"USD","date_created":"2012-11-15
> 02:51:29","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2)
> AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64
> Safari/537.11"}],"total_count":1}}
>
> On Fri, Aug 5, 2016 at 10:11 AM, Skip Kimpel <skiplondon at gmail.com> wrote:
>
> > Clarification:  I am looking to get the total_count value from this
> sample
> > JSON file:
> >
> > {"entries":[{"payment_date":null,"transaction_id":null,"6"
> > :"","1.6":"LName","payment_method":null,"is_fulfilled":
> > null,"form_id":2,"status":"active","post_id":null,"4":"This is just a
> > test","is_starred":0,"transaction_type":null,"is_
> > read":1,"id":1,"created_by":null,"source_url":"http://te.com/
> > ","payment_status":null,"3":"(561)222-5942","1.3":"
> > FName","ip":"71.229.127.176","payment_amount":null,"2":"g at test.com
> > ","5":"","currency":"USD","date_created":"2012-11-15
> > 02:51:29","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2)
> > AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64
> > Safari/537.11"}],"total_count":1}
> >
> > On Fri, Aug 5, 2016 at 9:59 AM, Skip Kimpel <skiplondon at gmail.com>
> wrote:
> >
> >> Good morning LC'ers!
> >>
> >> I have been able to successfully user mergJson to create a treeview of
> my
> >> JSON data, but I have a quick question:  If I wanted to get a specific
> >> value, several "levels" deep, how would I format that that code?
> >>
> >> Thank you for your help!
> >>
> >> SKIP
> >>
> >>
> >>
> >
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list