JSON Syntax And Rules For Create Websites
code , How to Use JSON language , JSON, syntex of JSON , Example Of JSON , JOSN Developer, Rules for JSON language.
JSON Syntax :
JSON Syntax Rules
JSON syntax is derived from JavaScript object notation syntax:
JSON Data - A Name and a Value
Example
"name":"John"
JSON - Evaluates to JavaScript Objects
JSON
{ "name":"John" }
JavaScript
{ name:"John" }
JSON Values
In JSON, values must be one of the following data types:
a string
a number
an object (JSON object)
an array
a boolean
null
In JavaScript values can be all of the above, plus any other valid JavaScript expression, including:
a function
a date
undefined
In JSON, string values must be written with double quotes:
JSON
{ "name":"John" }
In JavaScript, you can write string values with double or single quotes:
JavaScript
{ name:'John' }
<!DOCTYPE html>
<html>
<body>
<p>Access a JavaScript object:</p>
<p id="demo"></p>
<script>
var myObj, x;
myObj = { "name":"John", "age":30, "city":"New York" };
x = myObj.name;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
code , How to Use JSON language , JSON, syntex of JSON , Example Of JSON , JOSN Developer, Rules for JSON language.
JSON Syntax :
JSON Syntax Rules
JSON syntax is derived from JavaScript object notation syntax:
- Data is in name/value pairs
- Data is separated by commas
- Curly braces hold objects
- Square brackets hold arrays
JSON Data - A Name and a Value
Example
"name":"John"
JSON - Evaluates to JavaScript Objects
JSON
{ "name":"John" }
JavaScript
{ name:"John" }
JSON Values
In JSON, values must be one of the following data types:
a string
a number
an object (JSON object)
an array
a boolean
null
In JavaScript values can be all of the above, plus any other valid JavaScript expression, including:
a function
a date
undefined
In JSON, string values must be written with double quotes:
JSON
{ "name":"John" }
In JavaScript, you can write string values with double or single quotes:
JavaScript
{ name:'John' }
Example :
<!DOCTYPE html>
<html>
<body>
<p>Access a JavaScript object:</p>
<p id="demo"></p>
<script>
var myObj, x;
myObj = { "name":"John", "age":30, "city":"New York" };
x = myObj.name;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
Post a Comment