Javascript : Read/parse JSON data from HTTP response
This is just a quick note on how to parse JSON data with Javascript. The JSON data is generated in a similar fashion as described in the unmarshalling json data from http response tutorial, but for this tutorial sake, we just keep it as a string data in JSON format.
Basically, to process JSON data with Javascript. Just used the JSON.parse()
function will do.
For example :
var jsonData := '{"Name":"Adam","Age":36,"Job":"CEO"}'
var parsedData = JSON.parse(jsonData);
document.write(parsedData.Name + ", " + parsedData.Age + ", " + parsedData.Job);
Reference :
See also : Golang : Unmarshal JSON from http response
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+10.6k Swift : Convert (cast) String to Integer
+7.6k Golang : Individual and total number of words counter example
+14.9k Golang : GUI with Qt and OpenCV to capture image from camera
+20.2k Golang : Convert(cast) bytes.Buffer or bytes.NewBuffer type to io.Reader
+4.9k Linux/MacOSX : How to symlink a file?
+5.9k Get website traffic ranking with Similar Web or Alexa
+6.4k PHP : Get client IP address
+11.1k Golang : Removes punctuation or defined delimiter from the user's input
+6.9k Golang : Reverse by word
+7.7k Golang : Rot13 and Rot5 algorithms example
+5.5k Python : Delay with time.sleep() function example