JSON: Difference between revisions
Mr. MacKenty (talk | contribs) No edit summary |
No edit summary |
||
(13 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
[[file:Connection.png|right|frame|Web Science<ref>http://www.flaticon.com/</ref>]] | [[file:Connection.png|right|frame|Web Science<ref>http://www.flaticon.com/</ref>]] | ||
<syntaxhighlight> | JSON, it is an open-standard file format that uses human-readable text to transmit data objects consisting of attribute–value pairs and array data types. | ||
<syntaxhighlight lang="JavaScript"> | |||
{ | |||
"firstName": "Orest", | |||
"lastName": "Smith", | |||
"isAlive": true | |||
} | |||
# In the example above, firstname is an attribute, and the value is "Orest". | |||
</syntaxhighlight> | </syntaxhighlight> | ||
= | JSON (JavaScript Object Notation) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other serializable values). It is a common data format with diverse uses in electronic data interchange, including that of web applications with servers. | ||
JSON is a language-independent data format. It was derived from JavaScript, but many modern programming languages include code to generate and parse JSON-format data. JSON filenames use the extension .json.<ref>https://en.wikipedia.org/wiki/JSON</ref> | |||
<syntaxhighlight lang="JavaScript"> | |||
Example 1 - String Value Application | |||
JS: { name : 'Orest' } | |||
JSON: { "name" : "Orest" } | |||
Example 2 - Data Types | |||
a. Number | |||
b. String | |||
c. Boolean | |||
d. Array | |||
e. Object | |||
f. Null | |||
Example 3 - Short Biography of a Person in short facts | |||
{ | |||
"firstName": "Orest", | |||
"lastName": "Smith", | |||
"isAlive": true, | |||
"age": 27, | |||
"address": { | |||
"streetAddress": "21 2nd Street", | |||
"city": "New York", | |||
"state": "NY", | |||
"postalCode": "10021-3100" | |||
}, | |||
"phoneNumbers": [ | |||
{ | |||
"type": "home", | |||
"number": "123 654-7809" | |||
}, | |||
{ | |||
"type": "office", | |||
"number": "098 765-4321" | |||
}, | |||
{ | |||
"type": "mobile", | |||
"number": "123 456-7890" | |||
} | |||
], | |||
"children": [], | |||
"spouse": null | |||
} | |||
Example 4 - Parsing JSON in JS | |||
var p = JSON.parse(json_string); | |||
</syntaxhighlight> | |||
== References == | == References == |
Latest revision as of 20:49, 18 September 2022
JSON, it is an open-standard file format that uses human-readable text to transmit data objects consisting of attribute–value pairs and array data types.
{
"firstName": "Orest",
"lastName": "Smith",
"isAlive": true
}
# In the example above, firstname is an attribute, and the value is "Orest".
JSON (JavaScript Object Notation) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other serializable values). It is a common data format with diverse uses in electronic data interchange, including that of web applications with servers.
JSON is a language-independent data format. It was derived from JavaScript, but many modern programming languages include code to generate and parse JSON-format data. JSON filenames use the extension .json.[2]
Example 1 - String Value Application
JS: { name : 'Orest' }
JSON: { "name" : "Orest" }
Example 2 - Data Types
a. Number
b. String
c. Boolean
d. Array
e. Object
f. Null
Example 3 - Short Biography of a Person in short facts
{
"firstName": "Orest",
"lastName": "Smith",
"isAlive": true,
"age": 27,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021-3100"
},
"phoneNumbers": [
{
"type": "home",
"number": "123 654-7809"
},
{
"type": "office",
"number": "098 765-4321"
},
{
"type": "mobile",
"number": "123 456-7890"
}
],
"children": [],
"spouse": null
}
Example 4 - Parsing JSON in JS
var p = JSON.parse(json_string);