JSON.parse helper

@emre I must be missing something here. I am trying to parse some JSON I can get it to parse status just fine but if I attempt to go to data and pull anything from there it wont work. Here is what I have tried.

var hash = JSON.parse(gethash);
var hashresult = hash.data[0].location[0].hash;

For the following JSON:

{"status":"success","total":1,"offset":0,"limit":20,"data":[{"location":{"id":25721,"address":"Moore's Dairy Creme","timezone":"America\/Chicago","hash":"d5a84a780dcaa8bd6e9af79dc7ecbbb5","country":"US","city":"Newark","state":"AR","mon_hours_close":"21:00:00","tue_hours_close":"21:00:00","wed_hours_close":"21:00:00","thu_hours_close":"21:00:00","fri_hours_close":"21:00:00","sat_hours_close":"21:00:00","sun_hours_close":"00:00:00","mon_hours_open":"10:00:00","tue_hours_open":"10:00:00","wed_hours_open":"10:00:00","thu_hours_open":"10:00:00","fri_hours_open":"10:00:00","sat_hours_open":"10:00:00","sun_hours_open":"07:00:00","shift_feedback":true,"message":"Welcome!  This is a message that will be visible to all employees.","created":"2017-07-05 21:46:52","modified":"2019-02-01 05:43:33","department_based_budget":false}}]}

image

I figured it out with JTR help. I have a big headache so I made a rookie mistake. I did not need the [0] on location.

1 Like

I am not even sure if I need that hash but the punch call says it needs hash to do a punch so im preparing anyway.

Ok well progress. The punch worked!

image

1 Like

Now how would I comma seperate if it has multiple values example Data has multiple user fields its only returning the first one. I know there has to be a way to set a comma delimiter

Now I cant seem to get this to work:

 {REPORT SQL DETAILS:SELECT PinCode FROM Users WHERE Name ='{SETTING:CURRENTUSER}'}

Anyone have any ideas? @emre any idea… i thought for sure this should work.

Setting? Thought it was.just.current user.as.its own tag.

Want there some extra helpers in place from when were were talking about user login action?

Did you tried adding a field selector?

{REPORT SQL DETAILS:SELECT PinCode FROM Users WHERE Name ='{SETTING:CURRENTUSER}':F.PinCode}
2 Likes

No I’ll try that. I tried everything but that.

Update: That worked thanks Emre