JSON refers to JavaScript Object Notation and it is an open standard format,
it uses human-readable text to transmit data object that contains attribute or
values. JSON is mostly used in between server and client for transmission of
data.
Syntax:
[
{
name1:value1,
name2:value2,
nameN:valueN
},
{
name1:value1,
name2:value2,
nameN:valueN
}
]
Example:
HTML Document (format.html)
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8"/>
<title>JSON</title>
</head>
<body>
<h2>Example of JSON Format</h2>
<p id="content"></p>
<script>
var courses = [
{
"title":"HTML",
"description":"Hypertext Markup Languag"
},
{
"title":"JSON",
"description":"JavaScript Object Notation"
},
{
"title":"PHP",
"description":"Hypertext Preprocessor"
}
];
document.getElementById("content").innerHTML =
courses[0].title + ": " + courses[0].description + "<br/>" +
courses[1].title + ": " + courses[1].description + "<br/>" +
courses[2].title + ": " + courses[2].description;;
</script>
</body>
</html>
No comments:
Post a Comment