CodeNewbie Community 🌱

Discussion on: What's the difference between JSON and a plain string?

Collapse
 
djuber profile image
Daniel Uber • Edited

Hi, Sophie!

JSON is a way to encode data like arrays, numbers, hashes/dictionaries/maps, true, false, and other strings, in a way that can be sent over a network (it's a kind of serialization), or saved in a file for easy reading later. For the kinds of objects it can describe correctly, there's a way to take an object, turn it into a string, and given that string produce a copy of the same object. This is very useful for moving copies of data from a server to a web-browser, to use a concrete example.

A "plain string" would mean a string (probably not also a JSON encoded object) that represents some text value like "plain string" or the contents of the last book you read. It's a very flexible format (we've been using it since the beginning of computers, for sure) and you'll want to know how to use them.

Usually "plain strings" are intended for humans, and JSON is intended for machines (you can view it, since it's text, but it will look a lot more like code than speech).

For example, this page is available as html (the webpage you're probably looking at) and as a json description of this page (here ) - the feed of articles at community.codenewbie.org you see is drawn in your browser after we fetch a list from the site (the copy I got included this page, here and was automatically fetched during looking at the site).