Introduction to JSON
JavaScript Object Notation
JSON is
Source https://www.json.org/
JSON is a text format that is completely programming language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others.
These properties make JSON an ideal data-interchange language.
Source https://www.json.org/
This is an example of a JSON object
{
"name": "Matt Damon",
"bornInYear": 1970,
"academyAwards": null,
"appearsIn": ["Ocean's 11", "Invictus", "The Martian"]
}
At first glance, a JSON object looks very similar to a Ruby Hash, but there are some major differences:
null
It's very crucial to understand, that JSON is just a text document.
With JSON itself we cannot do anything programmatically.
So, even if the syntax looks similar to a Ruby Hash, they're actually different.
Anyway, following slides describe some syntactic differences between a JSON object and a Ruby Hash.
JSON |
Ruby |
---|---|
|
|
JSON |
Ruby |
---|---|
|
|
nullvs
nil
JSON |
Ruby |
---|---|
|
|
nullin JSON and
nilin Ruby.
Using these two structures we can describe any kind of data.
Source https://www.json.org/
JSON |
Ruby |
---|---|
|
|
caretakers) or Objects (see
location) again.
JSON |
Ruby |
---|---|
|
|
JSON |
Ruby |
---|---|
|
|
What questions do you have?