JSON Examples

Get Data from a JSON File


Get my Resume that is stored in 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 a JSON File # 2


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"
}
]