JSON - JavaScript Object Notation
Often JSON is confused with JavaScript Object
It is JavaScript based approach to data exchange.
It is an alternative for xml.
Often JSON is confused with JavaScript Object
It is JavaScript based approach to data exchange.
It is an alternative for xml.
Advantages -
1.Lighter and more Flexible than xml.
2.Language Independent
It can transfer data from one language to another without modification (serialization).
JavaScript Object Literal -
It is JavaScript object with key value pair .
Eg. var name = {"fname":"Tushar","lname":"Patil"};
Conditions -
1.Key must be a String.
2.Key does not need double quotes unless it is JavaScript reserved word.
Value can be anything such as Object ,function, Array, Nested Objects etc.
How to access properties of JavaScript Object Literals?
1. dot notation - (Refer above example)
name.fname
name.lname
2.braces -
name['fname'];
name['lname'];
How JSON is Different from JavaScript Object Literal ?
Since JSON is supported throughout almost all languages, it has different set of conditions to be met.
Conditions -
1. All keys and strings must have double quotes.
2. Functions are not a supported data type.
Data Types in JSON-
As same as JavaScript data Types except Functions.
JavaScript Object Literal -
It is JavaScript object with key value pair .
Eg. var name = {"fname":"Tushar","lname":"Patil"};
Conditions -
1.Key must be a String.
2.Key does not need double quotes unless it is JavaScript reserved word.
Value can be anything such as Object ,function, Array, Nested Objects etc.
How to access properties of JavaScript Object Literals?
1. dot notation - (Refer above example)
name.fname
name.lname
2.braces -
name['fname'];
name['lname'];
How JSON is Different from JavaScript Object Literal ?
Since JSON is supported throughout almost all languages, it has different set of conditions to be met.
Conditions -
1. All keys and strings must have double quotes.
2. Functions are not a supported data type.
Data Types in JSON-
As same as JavaScript data Types except Functions.
No comments:
Post a Comment