CodeNewbie Community


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

Writer turned wanna-be developer.
・1 min read

Hi CodeNewbies! I just came up against the issue of JSON vs. plain strings and was hoping someone could help illuminate it for me.

So, can anyone explain what the difference is between JSON and a plain string?

Many thanks!

Discussion (2)

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 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).

jasonbraganza profile image
Jason Braganza

A string is a sequence of characters. Something, something. La di dah. 👈 That is a string.

The way I understand JSON is like the entries in a paper dictionary. there is an item and then there is something related to it, some description, some explanation in front of it.

Like a normal dictionary entry would be
flibbertigibbet: a silly flighty person


hootenanny: a gathering at which folk singers entertain often with the audience joining in

Now computers like it when stuff is presented in such a manner. it maps well with a certain way they like to process data. they can process strings or lists, but when stuff is presented as what Python calls dictionaries or JavaScript calls HashMaps, they can process these things really fast.
Which is why most computers like to speak JSON. and most languages have libraries that can convert to and from JSON.

Like @djuber pointed out, even the data on this page could be represented as JSON

"title": "What's the difference between JSON and a plain string?" //this is the title of the page
"created_at": "2021-04-27T20:38:32.464Z" //this was when the post was created

or we could have names and addresses or we could have flights and destinations or what have you.
A whole host of data, can be quickly and flexibly represented in JSON

Hope this helps :)