<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: André Roberto Figueiró de Magalhães</title>
    <description>The latest articles on DEV Community by André Roberto Figueiró de Magalhães (@magalhaes).</description>
    <link>https://dev.to/magalhaes</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F226422%2F8610c5ff-a00a-4eb4-a528-8d2e6be43bc7.jpeg</url>
      <title>DEV Community: André Roberto Figueiró de Magalhães</title>
      <link>https://dev.to/magalhaes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/magalhaes"/>
    <language>en</language>
    <item>
      <title>Why Would You Use {JSON}?
</title>
      <dc:creator>André Roberto Figueiró de Magalhães</dc:creator>
      <pubDate>Wed, 13 May 2020 15:00:45 +0000</pubDate>
      <link>https://dev.to/magalhaes/why-would-you-use-json-31p3</link>
      <guid>https://dev.to/magalhaes/why-would-you-use-json-31p3</guid>
      <description>&lt;h1&gt;
  
  
  Why Would You Use JSON?
&lt;/h1&gt;

&lt;p&gt;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 &lt;a href="https://www.linkedin.com/in/magalhaes-andre/"&gt;LinkedIn&lt;/a&gt;.&lt;br&gt;
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.&lt;br&gt;
Now that i'm introduced, let me ask you: &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Why Would You Use JSON???&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Back-end at Its Finest
&lt;/h2&gt;

&lt;p&gt;Back-end softwares have in general one important task, that in most cases are the core of it:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DEALING WITH THE DATA&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;And &lt;em&gt;how&lt;/em&gt; would i do that? It's up to you actually:&lt;/p&gt;

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

&lt;p&gt;Whatever the scenario is, it's probably a data dealing scenario. So what this means essentialy?&lt;br&gt;
It means two things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You'll have to receive that data somehow (Input)&lt;/li&gt;
&lt;li&gt;You'll have to send this data somewhere (Output)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;There are variations to this complex formula, but in essence...&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Input?
&lt;/h2&gt;

&lt;p&gt;The entrance to your application, the front door, the main way of taking a chat with your great logic state of the art production.&lt;/p&gt;

&lt;p&gt;You can build it just anyway you'd like. But...&lt;/p&gt;

&lt;p&gt;Maybe you will agree with me on this:&lt;/p&gt;

&lt;p&gt;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 &lt;em&gt;(almost)&lt;/em&gt; everyone uses and makes communication such a common matter into development?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IT EXISTS&lt;/strong&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Is JSON the One?
&lt;/h2&gt;

&lt;p&gt;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:&lt;/p&gt;
&lt;h2&gt;
  
  
  XML (Or: Why You're Not Using JSON)
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What rules are those?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For a further look and even for starters i would recommend &lt;a href="https://www.w3schools.com/xml/"&gt;to follow this steps.&lt;/a&gt; But! If you just want a glance into what a XML file would be, here you go!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?xml version=1.0&amp;gt;
    &amp;lt;PERSON&amp;gt;
        &amp;lt;HEIGHT&amp;gt;1.98&amp;lt;/HEIGHT&amp;gt;
        &amp;lt;WEIGHT&amp;gt;100&amp;lt;/WEIGHT&amp;gt;
        &amp;lt;NAME&amp;gt;Vince Carter&amp;lt;/NAME&amp;gt;
        &amp;lt;POSITION&amp;gt;SG/SF&amp;lt;/POSITION&amp;gt;
    &amp;lt;/PERSON&amp;gt;
&amp;lt;/xml&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;h2&gt;
  
  
  JSON
&lt;/h2&gt;

&lt;p&gt;Here, the same example would look something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "person": {
        "height": 1.98,
        "weight": 100,
        "name": "Vince Carter",
        "position": "SG/SF"
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Oh Well, But i Prefer XML/ I Work in a Old School Codebase
&lt;/h2&gt;

&lt;p&gt;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?":&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Use what makes sense to your project.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I think this could be a constant with no effort.&lt;/p&gt;

&lt;p&gt;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.)&lt;/p&gt;

&lt;p&gt;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).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Thanks for reading it this far!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;&lt;a href="https://github.com/magalhaes-andre"&gt;magalhaes.getGithub()&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>json</category>
      <category>backend</category>
      <category>data</category>
    </item>
  </channel>
</rss>
