samedi 21 mars 2015

Need advice on how to get results or number of results from JSON object


I need some assistance in getting the results from a JSON object with javascript or jquery. I have searched on google and stackoverflow, only to end up tearing my hair out! the JSON object contains the following JSON information in this format:





{ "U2" : "1619342707",
"Wv" : [ ],
"Xv" : [ ],
"hra" : "0.6",
"p3" : "ok",
"q" : "{\"cols\":[{\"id\":\"A\",\"label\":\"PSUID \",\"type\":\"number\",\"pattern\":\"General\"},{\"id\":\"B\",\"label\":\"FirstName\",\"type\":\"string\"},{\"id\":\"C\",\"label\":\"LastName\",\"type\":\"string\"},{\"id\":\"D\",\"label\":\"Age\",\"type\":\"number\",\"pattern\":\"General\"},{\"id\":\"E\",\"label\":\"Street\",\"type\":\"string\"},{\"id\":\"F\",\"label\":\"City\",\"type\":\"string\"},{\"id\":\"G\",\"label\":\"State\",\"type\":\"string\"},{\"id\":\"H\",\"label\":\"Zipcode\",\"type\":\"number\",\"pattern\":\"General\"},{\"id\":\"I\",\"label\":\"PhoneNumber\",\"type\":\"string\"},{\"id\":\"J\",\"label\":\"PSUEmail\",\"type\":\"string\"},{\"id\":\"K\",\"label\":\"ApplySemYear\",\"type\":\"string\"},{\"id\":\"L\",\"label\":\"Majors\",\"type\":\"string\"},{\"id\":\"M\",\"label\":\"WhichCollege\",\"type\":\"string\"},{\"id\":\"N\",\"label\":\"VolunteerType\",\"type\":\"string\"},{\"id\":\"O\",\"label\":\"WhyVolunteer\",\"type\":\"string\"},{\"id\":\"P\",\"label\":\"Class\",\"type\":\"string\"},{\"id\":\"Q\",\"label\":\"ClassHours\",\"type\":\"string\"},{\"id\":\"R\",\"label\":\"Organization\",\"type\":\"string\"},{\"id\":\"S\",\"label\":\"OrgHours\",\"type\":\"number\",\"pattern\":\"General\"},{\"id\":\"T\",\"label\":\"Skills\",\"type\":\"string\"},{\"id\":\"U\",\"label\":\"Extracurricular\",\"type\":\"string\"},{\"id\":\"V\",\"label\":\"AdditionalInfo\",\"type\":\"string\"},{\"id\":\"W\",\"label\":\"Agreement\",\"type\":\"string\"},{\"id\":\"X\",\"label\":\"\",\"type\":\"string\"},{\"id\":\"Y\",\"label\":\"\",\"type\":\"string\"},{\"id\":\"Z\",\"label\":\"\",\"type\":\"string\"}],\"rows\":[{\"c\":[{\"v\":44444,\"f\":\"44444\"},{\"v\":\"jake\"},{\"v\":\"thomson\"},{\"v\":43,\"f\":\"43\"},{\"v\":\"4544 roman drive\"},{\"v\":\"houston\"},{\"v\":\"texas\"},{\"v\":76565,\"f\":\"76565\"},{\"v\":\"656-444-4431\"},{\"v\":\"homer@homder.com\"},{\"v\":\"Spring 2015\"},{\"v\":\"biology\"},{\"v\":\"PSU\"},{\"v\":\"mentor\"},{\"v\":\"Organization\"},{\"v\":\"none\"},{\"v\":\"none\"},{\"v\":\"phi kappa beta\"},{\"v\":34,\"f\":\"34\"},{\"v\":\"computers\"},{\"v\":\"volleyball\"},{\"v\":\"none\"},{\"v\":\"terms agreed\"},null,null,{\"v\":null}]}]}"
}



Actually, I am trying to see if the JSON object has any results from my query to the server. Is there a way to get how many rows of data the JSON object contains? I think is is the most important piece of information I need. If I do this Object.keys(response).length it always returns the number 6, regardless of how many records it contains. Any help would be much appreciated.





Aucun commentaire:

Enregistrer un commentaire