I am a javascript noob. I have a JSON string created by google gson API after creating the json string which I am passing it to my javascript function. So in a javascript variable I have a string as follows
'{"validationCode":"V10291","caseNumber":"2010CF101011","documentSource":"EFILE","countyDocumentID":"CD102","documentTitle":"D Title","signedDate":"01/01/2012","signedBy":"CPSJC","comments":"YES Comments"}'
How to iterate over this or get a value of the key something like I have to find validationCode or caseNumber, but this is String? Any suggestions are welcome
You can get it into a native JavaScript object with
JSON.parse:Then you can iterate the keys with a standard for in loop
Or access particular keys like
validationCodeorcaseNumberdirectly:Note that really old browsers don’t support
JSON.parse, so if you want to support them, you can either use Papa Crockford’s json2, or jQuery, which has a parseJSON utility method.