I’m tired of “sorta” understanding JSON and fighting with it in my projects, so I’m committing myself to learning the in’s-n-out’s over the next month. My plan is start with the basics and move along in separate blog posts.
Writing about enums a while back was very helpful to my overall understanding and how to use them effectively. Hopefully I’ll get the same benefit after I write a few posts about JSON. Honestly, slowing down and writing about the very basics of JSON has been extremely helpful already.
JSON Data Basics - Recognition
I get this, but didn’t really understand what it meant until breaking it down.
- JSON is text - a browser and a server can only exchange text data.
Sending JSON Data
- Convert the object to JSON.
stringify()is a function that creates a string (text) from the object.
- Send it (text) to the server.
Receiving JSON Data
Most of the time I’m the one receiving data and then putting it into my app or website. A couple important points to keep in mind… JSON Data always includes key/value pairs & JSON keys must be strings with double quotes -> “jsonKey”
See the Pen JSON Basics - Receive Data by doug harper (@endodoug) on CodePen.
- JSON received is comes as a string (text.)
- Do something with the new object, like displaying it
Next up -> See how this plays out with Swift.
- Lynda.com - Processing and Interchanging JSON Data by Sasha Vodnic