<?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: Angel Barre</title>
    <description>The latest articles on DEV Community by Angel Barre (@bytecodesky).</description>
    <link>https://dev.to/bytecodesky</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%2F646301%2Fb60d7966-ce42-444b-888d-d92d609c8023.png</url>
      <title>DEV Community: Angel Barre</title>
      <link>https://dev.to/bytecodesky</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bytecodesky"/>
    <language>en</language>
    <item>
      <title>All you need to know about JSON?</title>
      <dc:creator>Angel Barre</dc:creator>
      <pubDate>Sun, 09 Jun 2024 07:25:36 +0000</pubDate>
      <link>https://dev.to/bytecodesky/test-hka</link>
      <guid>https://dev.to/bytecodesky/test-hka</guid>
      <description>&lt;h2&gt;
  
  
  What is JSON?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  JSON stands for JavaScript Object Notation
&lt;/h3&gt;

&lt;p&gt;It is an open standard file format and data exchange format that employs text that humans can read to store and send data objects made up of attribute-value pairs and arrays (or other serializable values). It is a widely used data format for electronic data exchange, notably between servers and online applications.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Strings : &lt;code&gt;"Angel Barre" "Hello World"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Numbers: &lt;code&gt;13 0.6 -21&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Booleans: &lt;code&gt;true, false&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Arrays : &lt;code&gt;[1,2,3] ["Hi", "Dev"]&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Objects: &lt;code&gt;{"key":"value", "name": "Angel"}&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: &lt;em&gt;JSON names require double quotes. JavaScript names do not.&lt;/em&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Data is in name/value pairs&lt;/li&gt;
&lt;li&gt;Commas are used to separate data&lt;/li&gt;
&lt;li&gt;Curly braces hold objects&lt;/li&gt;
&lt;li&gt;Square brackets hold arrays
### Example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="s2"&gt;"Angel"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
    &lt;/span&gt;&lt;span class="nl"&gt;"age"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; 
    &lt;/span&gt;&lt;span class="nl"&gt;"isDeveloper"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"languages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"HTML"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;"CSS"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;"JavaScript"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s2"&gt;"PHP"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"Idk"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"pets"&lt;/span&gt;&lt;span class="p"&gt;:[{&lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Robert"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Dog"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
                &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Max"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Cat"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;}]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How to access data from a JSON file or Object?
&lt;/h2&gt;

&lt;p&gt;If we load this data as a variable called info, we could then access the data inside it using the same dot/bracket notation. For example:&lt;br&gt;
&lt;code&gt;info.name&lt;/code&gt; or &lt;code&gt;info['name']&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Output:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="s2"&gt;"Angel"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;info.pets[1].name&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Output
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="s2"&gt;"Max"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;info.languages[2]&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Output
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="s2"&gt;"JavaScript"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Why use JSON?
&lt;/h2&gt;

&lt;p&gt;The syntax of the JSON format is similar to that of the JavaScript object creation code. This makes it simple for a JavaScript code to turn JSON data into JavaScript objects.&lt;/p&gt;

&lt;p&gt;JSON data may be used in any programming language and is easily transferable between machines because it is merely in text format.&lt;/p&gt;

&lt;h2&gt;
  
  
  Things to keep in mind while writing JSON
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;JSON consists solely of a string with a predefined data format.It has no methods,only properties.&lt;/li&gt;
&lt;li&gt;JSON requires double quotes to be used around strings and property names. Single quotes are invalid.&lt;/li&gt;
&lt;li&gt;A single missed comma or colon might cause a JSON file to stop working.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
