DEV Community

Cover image for Why Would You Use {JSON}?
André Roberto Figueiró de Magalhães
André Roberto Figueiró de Magalhães

Posted on • Updated on

Why Would You Use {JSON}?

Why Would You Use JSON?

So, here we go... As this is my first post around here, maybe it would be nice to present myself, and probably from a work perspective, the most resumed glance you can have of me, would come from my LinkedIn.
And for the ones lacking time to take a look, until this day () i've been mainly a back-end developer (leave in the comment section how you write back end/back-end/backend). This means that i've dealed a lot with Java, frameworks, APIs and microservices, some devops too.
Now that i'm introduced, let me ask you:

Why Would You Use JSON???

Back-end at Its Finest

Back-end softwares have in general one important task, that in most cases are the core of it:


And how would i do that? It's up to you actually:

  • Will you need a database? (Most of the times, this is a yes.)
  • Will you be talking to another API(Application Programming Interface / A program to talk to.)?
  • Will you only do a calculation over variables passed to you?

Whatever the scenario is, it's probably a data dealing scenario. So what this means essentialy?
It means two things:

  1. You'll have to receive that data somehow (Input)
  2. You'll have to send this data somewhere (Output)

There are variations to this complex formula, but in essence...


The entrance to your application, the front door, the main way of taking a chat with your great logic state of the art production.

You can build it just anyway you'd like. But...

Maybe you will agree with me on this:

Every door has a resemblance to one another. Probably will have some mechanism to open it. Maybe anyone can open it, maybe it needs some special access (keys/tokens), but it makes sense that most doors have a similar look. So, wouldn't be awesome if there existed some magical pattern that (almost) everyone uses and makes communication such a common matter into development?


Is JSON the One?

Nope, at least, it surely wouldn't be the only option, that's for sure, we already had/have some other options pretty common on defining communication. Between them, the one that stand out more and probably the most common besides JSON would be:

XML (Or: Why You're Not Using JSON)

Just kidding (not so much), XML stands for Extensible Markup Language. What does it means? It means that this language has some set of rules for creating a pattern readable determining how to markup information that will be read into your application.

What rules are those?

For a further look and even for starters i would recommend to follow this steps. But! If you just want a glance into what a XML file would be, here you go!

<?xml version=1.0>
        <NAME>Vince Carter</NAME>
Enter fullscreen mode Exit fullscreen mode

Does the above seems nice to read? Maybe, since there is a relative low quantity of information, but there are more readable options, like:


Here, the same example would look something like:

    "person": {
        "height": 1.98,
        "weight": 100,
        "name": "Vince Carter",
        "position": "SG/SF"
Enter fullscreen mode Exit fullscreen mode

At least for me it is a considerable number of times more readable and less tiring, just by removing the need of starting a attribute and needing to end it with itself and a slash up front.

The JSON notation reflects much more of a object representation would be, and even on contexts that are not Object Oriented the transport of the message itself becomes much more clearer and simpler than the XML option.

Oh Well, But i Prefer XML/ I Work in a Old School Codebase

Well, no problem then, as all of the tools we have for coding, they all face the most common discussion that generally sounds as "should i use this?/should i use that?":

Use what makes sense to your project.

I think this could be a constant with no effort.

Do you want to be the only person using json while every other service/section of your code is expecting a xml? (Please, answer no.)

Surely JSON seems like a cleaner option, but it doesn't mean it is the only one, it serves for communication, and communication has the sole purpose of being understood (at least in computing).

Thanks for reading it this far!


Top comments (2)

davidcockerill profile image

JSON gets my vote! I like that it "reflects much more of a object representation". It's also less verbose, readable and easy to parse.

magalhaes profile image
André Roberto Figueiró de Magalhães

Sure! 100% agree, i think that as far as we can go maintaining the mirroring of what our code really represents, that is almost always the way to go!