gerritvankuipers / aspjson

Classic ASP JSON Class Reading/Writing
78 stars 39 forks source link

Nested JSON File Issue #24

Open emzipoo4u opened 1 year ago

emzipoo4u commented 1 year ago

The httpResponse text looks like...

  {"returnObj":{"LaborHed": 
    [{"Company":"MYCOMPANY","EmployeeNum":"A","LaborHedSeq":106,"PayrollDate":"2022-10- 
    06T00:00:00","Shift":11,"ClockInDate":"2022-10-05T00:00:00",

According to other posts on this topic it looks as though the issue I am getting is because the response is nested in "returnObj": though i can't see how to resolve. Please can I have an example of parsing the above response.

ThorvaldAagaard commented 1 year ago

Could you give the error code you get?

The response looks incomplete, so I am not able to test it

I think it is the array, that is causing trouble, but i have tried

{"Status":0,"TC":false,"RD":true,"RA":true,"AD":true,"CD":false,"Question":[{"name":"netbridge.dk.","type":15}],"Answer":[{"name":"netbridge.dk.","type":15,"TTL":3600,"data":"10 alt3.aspmx.l.google.com."},{"name":"netbridge.dk.","type":15,"TTL":3600,"data":"1 aspmx.l.google.com."},{"name":"netbridge.dk.","type":15,"TTL":3600,"data":"5 alt2.aspmx.l.google.com."},{"name":"netbridge.dk.","type":15,"TTL":3600,"data":"10 alt4.aspmx.l.google.com."},{"name":"netbridge.dk.","type":15,"TTL":3600,"data":"5 alt1.aspmx.l.google.com."}],"Comment":"Response from 185.25.141.15."}

then calling

oJSON.loadJSON() oJSON.JSONoutput())

and getting this result result

{ "Status": 0, "TC": false, "RD": true, "RA": true, "AD": true, "CD": false, "Question": [ { "name": "netbridge.dk.", "type": 15 } ], "Answer": [ { "name": "netbridge.dk.", "type": 15, "TTL": 3600, "data": "10 alt3.aspmx.l.google.com." }, { "name": "netbridge.dk.", "type": 15, "TTL": 3600, "data": "1 aspmx.l.google.com." }, { "name": "netbridge.dk.", "type": 15, "TTL": 3600, "data": "5 alt2.aspmx.l.google.com." }, { "name": "netbridge.dk.", "type": 15, "TTL": 3600, "data": "10 alt4.aspmx.l.google.com." }, { "name": "netbridge.dk.", "type": 15, "TTL": 3600, "data": "5 alt1.aspmx.l.google.com." } ], "Comment": "Response from 185.25.141.15." }

But unable to get the array using any code

So perhaps you can try to serialize and the deserialize?

I found btw that

For Each i In oJSON.data("Answer").Items
    response.write i.item("data") 
Next 

can access the data