JSON Examples



Get my Resume from a JSON File







Create Object from JSON String



Here is the hardcoded JSON string in the Javascript function:

var text = '{"employees":[' + '{"firstName":"John","lastName":"Doe" },' + '{"firstName":"Anna","lastName":"Smith" },' + '{"firstName":"Peter","lastName":"Jones" }]}';

Data will be displayed below the button after you press it.








Get Data from an External JSON File


Here is what the JSON file that's being read looks like:

[
{
"name" : "Apple",
"color" : "red",
"origin": "U.S."
},
{
"name" : "Orange",
"color" : "orange",
"origin": "U.K."
},
{
"name" : "Strawberry",
"color" : "red",
"origin": "Japan"
}
]