Working with JSON for Web Development

This chapter will help you to learn JSON fundamentals, example, syntax, array, object, encode, decode, file, date and date format. You will also be able to learn JSON examples with other technologies such as Java and PHP.


We can get JSON data by AJAX code. AJAX provides facility to get response asynchronously. It doesn't reload the page and saves bandwidth.

<meta content="text/html; charset=utf-8">
<title>AJAX JSON by Javatpoint</title>
<script type="application/javascript">
function load()
var url = "";//use any url that have json data var request;
request=new XMLHttpRequest();//for Chrome, mozilla etc
else if(window.ActiveXObject){
request=new ActiveXObject("Microsoft.XMLHTTP");//for IE only
request.onreadystatechange = function(){
if (request.readyState == 4 )
var jsonObj = JSON.parse(request.responseText);//JSON.parse() returns JSON object
document.getElementById("date").innerHTML =;
document.getElementById("time").innerHTML = jsonObj.time;
}"GET", url, true);
Date: <span id="date"></span><br/>
Time: <span id="time"></span><br/>
<button type="button" onclick="load()">Load Information</button>