Open In App

What is JSON text ?

The Javascript Object Notation(JSON) is used to transfer or exchange information on the internet. JSON is just the plain text written as a javascript object. There exist several key-value pairs which represent some useful information. 

The important thing to keep in mind is, although the JavaScript comes in the full form of JSON, it is not limited to the JavaScript programming language instead it’s just a representation of some information that can be used anywhere in any programming language, library, or framework. Several programming environments have features to parse and generate the JSON data.



Some Properties of JSON:

Use Cases of JSON:



Examples

Object JSON: This is the simple object containing the information of geeks for geeks.




{
  "name": "GeeksforGeeks",
  "about": "A portal for Computer Science Geeks to read the articles related",
  "additionalDescription": "It also provides some Courses",
  "founder": "Sandeep Jain",
  "mail": "feedback@geeksforgeeks.org",
  "address": "Sector-136, Noida, Uttar Pradesh - 201305"
}

Array JSON: This is a simple JSON of an array containing the list of the few courses of geeks for geeks.




[
    {
      "name": "Data Structures with C++ Live",
      "description": "A course specially designed for C++ enthusiasts",
      "whatYouWillLearn": [
        "Mastering DS from basic to advanced level",
        "Solving problems which are asked in product-based companies",
        "How to become a strong and efficient problem solver",
        "Enhance your problem-solving ability"
      ]
    },
    {
      "name": "JAVA Backend Development - Live",
      "description": "Learn backend development with Hibernate, RESTful APIs",
      "whatYouWillLearn": [
        "Redis & Kafka with Spring Boot",
        "Advanced Java",
        "Spring / Spring Boot",
        "Micro-services & related technologies used to build Java-based web applications"
      ]
    },
    {
      "name": "System Design - Live",
      "description": "LIVE System Design classes for individuals looking to crack SDE job",
      "whatYouWillLearn": [
        "How to design scalable systems",
        "Tips to crack system design interviews",
        "The intensity of the interview & how to manage your time",
        "Real-world example questions like designing system of Uber, Twitter etc.",
        "How to apply theory into application in real-time"
      ]
    }
  ]

JSON in Javascript: In javascript, we can simply create the JSON with the inbuilt stringify() method of javascript.




<script>
    const myObject = {
        a:1,
        b:"Some Text",
        c:[
            {
            key1:"property1"
            },
            {
            key2:"property2"
            },
            {
            key3:"property3"
            }
        ]
    };
console.log(JSON.stringify(myObject));
</script>

Output:- When we open the index.html file containing the above code snippet in the browser, this will happen in the console. 


Article Tags :