Understanding Json 1722831556
Understanding Json 1722831556
com
JAVASCRIPT
JSON
OBJECT NOTATION
sosamson.com
JSON
JSON stands for JavaScript Object Notation.
JSON is a lightweight format for storing & transporting
data.
JSON is "self-describing" and easy to understand.
JSON is often used when data is sent from a server to a
web page.
[{”cit
Client y”:”pa
ris”,
“unit
s”:”c”
}] Server
JSON
Request /service/weather
Response
HTTP POST (REST Interface)
[{”low”:”16”, “high”:”23”}]
JSON EXAMPLE
{
“employees”:[
{”firstName” : ”John”, “lastName” : ”Doe”},
{”firstName” : ”Anna”, “lastName” : ”Smith”},
{”firstName” : ”Peter”, “lastName” : ”Jones”}
]
}
sosamson.com JSON.parse()
JSON.parse()
When receiving data from a web server, the data is
always a string.
sosamson.com JSON.stringify()
JSON.stringify()
The JSON.stringify() method converts a JavaScript object or
value to a JSON string, optionally replacing values if a replacer
function is specified or optionally including only the specified
properties if a replacer array is specified.
SYNTAX
JSON String
JavaScript Object
JSON.parse()
‘{
{
“language”:“JavaScript”,
language:‘JavaScript’,
“IDE”:“Visual Studio”, JSON.stringify()
IDE:‘Visual Studio’,
“Theme”:“dark”
Theme:‘dark’
}’
}
sosamson.com
JSON VALUES
in JSON, values must be one of the following data types:
string
number
object (JSON object)
array
boolean
null
JSON
JSON
sosamson.com