Blog

Exploring New Horizons of JSON – Part 2

April 15, 2020
Comments
Share

In the previous post, we discussed the declaration of arrays and objects in JSON. Now, in this blog, we will be discussing the values that can be used in JSON. Which means the values that can be utilized in arrays and objects. But first of all, we need to know about JSON values.

Values in JSON

No matter what you are going to declare as both the arrays and objects contain values. Below you will find the values that are systematically used or take place to exist as an inevitable factor in JSON data.

  •  Null
  • Number
  • Boolean, which translates either the given information is “True” or “False.”
  • String enclosed in double quotes
  • Array
  • Object

Assembling the Data Compactly – Twitter API

In case, you are looking to retrieve all the data from your twitter account, like the tweets of your twitter business account to assemble them and get insights about your previous strategies adopted for the twitter marketing campaign. Or looking into to dig up specific specified data with the help of keywords, you will have to obtain “JavaScript Object Notation,” which will be interpreted with a JavaScript object.

Below, I will demonstrate how to parse the JSON data,

Note: The data mentioned below is just an example, and the original data that you will receive will be slightly different from this one, but the retrieved data will be more or less the same.

Data of JavaScript Object Notation

To explain the process in the simplest way, the file type that will be used in the example will “.json” format. The file will encompass of all the data of JSON you want to retrieve, but along with that, you can also conduct AJAX call to the URL from where you want to retrieve the data.

{

  “data”: [

     {

        “id”: “Y15”,

        “from”: {

           “name”: “John Statham”, “id”: “1458633”

        },

        “message”: “JSON is the best alternate to XML”,

        “actions”: [

           {

              “name”: “Post”,

              “link”: “http://www.twitter.com/Y812324/posts/ Y812324”

           },

           {

              “name”: “Comment”,

              “link”: ” http://www.twitter.com/Y812324/posts/ Y812324″

           }

        ],

        “type”: “Tweet”,

        “created_time”: “2012-09-02T23:26:43+0000”,

        “updated_time”: “2012-09-02T23:27:44+0000”

     },

     {

        “id”: “Y39”,

        “from”: {

           “name”: “Angelina Smith”, “id”: “357206”

        },

        “message”: “Writing First JSON Code Snippet”,

        “actions”: [

           {

              “name”: “like”,

              “link”: ” http://www.twitter.com/Y812421/posts/ Y812421″

           },

           {

              “name”: “Comment”,

              “link”: ” http://www.twitter.com/Y812421/posts/ Y812421″

           }

        ],

        “type”: “tweet”,

        “created_time”: “2013-07-02T25:27:44+0000”,

        “updated_time”: “2013-07-02T25:27:44+0000”

     }

  ]

}

AJAX call to URL

If you want to retrieve the JSON data, then AJAX call will become necessary to execute the process.

$.getJSON( “twitter.json”, success);

Final Outcome

JSON is developed in a way that it automatically parses the data. But if the data is more complicated, you need to use JSON parsing tool to get appropriate or desired results. 

The process, as mentioned above is the simplification of the retrieval of JSON data. The process can become intricate if you want to get more insight data as it will need you to provide additional information to the server so that it can fetch the result for you without any errors. Now you have got to know about the horizons of JSON if you find this guide to be useful share with your friends and colleagues.  

jsononline.net
Comment

Leave a Reply

avatar
  Subscribe  
Notify of