Today I am learning about JSON on LinkedIn Learning because I opened a link to have free access to it for 24 hours. Here are some of my notes.
- JSON stands for JavaScript Object Notation, even though it has slightly different rules than regular JSON objects
- Use only double quotes for keys and strings. Numbers and Boolean values need no quotes.
- In numbers, there may be no leading zeroes or trailing decimals
- There may be no trailing commas
- There are no comments in JSON, only in regular JS objects
I also learned along the way that GitHub has branches that can be used to track versions of files for things like tutorials.
- Json.org and the Wikipedia page for JSON are good resources to learn more about JSON
- There are sub versions of JSON but it is best to stick with the main one
Slightly more advanced concepts
I had never heard about some of these concepts:
- JSON supports nesting, so JSON values can be arrays
- Serializing means converting to JSON
- De-serializing means converting it from JSON to something else (useful so you can work with it in other languages)
- Json.parse is used to convert it to something that the code can use
- JSON can encode as either an object or an array
- You can use dot notation to access JSON values once the data is parsed.
- You may need to also learn XML or YAML when building real-world JSON projects
- JSON.stringify turns JSON and JS variables into a string
- JSON strings are used in HTTP requests and the whole structure of the internet
- JSON.parse and JSON.stringify are used to go back and forth between JSON and data structures in JavaScript
- If you are working in another programming language, you may need to learn other coding tools to work with JSON.
- Search suggestions are made possible with JSON
- Order confirmation emails are made with JSON
- You can see the HTTP requests in the developer tools in the browser, and open JSON files through there
- Some URLS will just return JSON data
- Browsers can usually parse the JSON data for the humans using it to make it more readable
- You can use code libraries to convert JSON to XML, YAML, or CSV
- JSON-P is “JSON with padding” and it is less secure, use CORS instead
- Be aware of Cross Site Script Injection (XSSI). The code “while(1);” is often used to prevent this. You need to add a statement to clean the data and use the slice method to remove the first 9 characters.
Unfortunately, I ran out of time to complete the course on my main account. I will have to learn more about JSON elsewhere.
Leave a Reply