Skip to main content

Introduction to JSON – Part 1

json-img
JSON is a data interchange format, frequently used for data exchange between clients and servers across the web. I am dividing this short tutorial series into three parts just to make it easy for you to understand. Part 1 is an introduction to JSON. It shows what is JSON, its structures are and how to write a JSON document. Part 2 explains How to process JSON in JAVA. The last part includes JSON Serialization. Hold your breath, a lot is coming up.
JSON, short for JavaScript Object Notation is a lightweight format which makes data exchange more than easier. It is also used to store data. JSON is language independent. For example, you can make a JSON Object in java and send it to a C# program which will gracefully handle it. JavaScript object can be converted into a JSON object and vice versa.
A JSON document can have two structures.

  • JSON Object: A name value pair or a key value pair. Names/Keys are only strings however values are of various types. Name and value are separated by a single colon (:). JSON Object is contained within the curly braces.


Name : Value,
}

  • JSON Array: An ordered sequence of values stored in square braces separated by a comma.

[
Value,
]
Types of Values: These types should be familiar to you and may not need any explanation. A value can be a

  1. String
  2. Number
  3. Bool (True/False)
  4. JSON Object
  5. JSON Array

A JSON value can also be null.
The file which contains JSON data is stored with .json extension. Following is an example document named Example.json. Study it and identify different structures and value types.
Example: Example.json
{
"first_name": "Salman",
"last_name": "Ahmad",
"gender": "male",
"age": 22,
"hobbies": [
"video games",
"drawing",
"music"
],
"fav_books": [
{
"name": "The Shallows",
"author": "Nicholas G. Carr"
},
{
"name": "Brain Bugs",
"author": "Dean Buonomano"
}
]
}
Next is How to process JSON data in JAVA. We will use this example in our code. See you there.

Comments

Post a comment

Popular posts from this blog

How Big Data Analytics Can Help You Improve And Grow Your Business?

Big Data Analytics There are certain problems that can only solve through big data. Here we discuss the field big data as "Big Data Analytics". The big data came into the picture we never thought how commodity hardware is used to store and manage the data which is reliable and feasible as compared to the costly sources. Now let us discuss a few examples of how big data analytics is useful nowadays. When you go to websites like Amazon, Youtube, Netflix, and any other websites actually they will provide some field in which recommend some product, videos, movies, and some songs for you. What do you think about how they do it? Basically what kind of data they generated on these kind websites. They make sure to analyze properly. The data generated is not small it is actually big data. Now they analysis these big data they make sure whatever you like and whatever you are the preferences accordingly they generate recommendations for you. If you go to Youtube you have noticed it kn…

How Computers Understand Human Language?

How Computers Understand Human Language? Natural languages are the languages that we speak and understand, containing large diverse vocabulary. Various words have several different meanings, speakers with different accents and all sorts of interesting word play. But for the most part human can roll right through these challenges. The skillful use of language is a major part what makes us human and for this reason the desire for computers that understand or speak human language has been around since they were first conceived. This led to the creation of natural language processing or NLP.
Natural Language Processing is a disciplinary field combining computer science and linguistics. There is an infinite number of ways to arrange words in a sentence. We can't give computers a dictionary of all possible sentences to help them understand what humans are blabbing on about. So, an early and fundamental NLP problem was deconstructing sentences into small pieces which could be more easily…

The Limits of Artificial Intelligence

If you are here, it means that you are familiar with term artificial intelligence. Either you have read about it in school or have seen it in sci-fi movies or somewhere else. Talking about the limitations of AI, let me ask you one simple question first, do you know the definition of AI? You might be thinking to answer me with a yes, yes I know what is artificial intelligence. But what if I tell you that AI is a buzzword and it is almost impossible to properly define. It is this way because the definition of artificial intelligence is moving. People don’t call the things AI that they used to call. For example, a problem that seemed too complex to be solved by human and was solved by AI algorithm is no longer a problem of AI. Playing chess, is one of the examples. It was considered the peek level of artificial intelligence back in previous century. Now it hardly fits the criteria for AI. It is presented to the world as a super power that when given to a computer, it magically starts li…