Reading list Switch to dark mode

    Introduction to JSON-LD

    Updated 2 November 2017

    JSONLD, or JavaScript Object Notation for Linked Data, is a method of encoding Linked Data using JSON.

    Before talking about JSON-LD let’s first understand what is Linked Data? Linked data is a way of publishing structured data so that; it has more relationship with its conclusive meaning or logic.Linked data is about applying the principles of the web to sharing data and doing so at a deeper level. In linked data, we can give each thing or data an individual identity or URI so that it can be identified uniquely.

    Let’s take an example if we want to publish information about each hotel in India then we would need a URI for each hotel by which we can identify it. After that, we will be able to publish information about each hotel in a small set of statements such as its name, address, company etc. If a hotel is operated by a company which is represented by their respective URI then we are creating a web of linked information. The company URI gives us the information about its name, headquarter, budget etc. This helps us in a lot of ways, such as the data is linked and is placed in context with each other which helps in allowing explanation and implication linked directly to data.

    When linked data concept is applied with JSON we are able to get encoded linked data. It is an implementation format for structuring data analogous to Microdata and RDFa. JSON-LD is considered to be simpler to implement, due to the ability to simply paste the markup within the HTML document, versus having to wrap the markup around HTML elements.

    JSON-LD annotates elements on a page, structuring the data, which can then be used by search engines to remove the uncertainty of meaning from elements and establish facts around surrounding entities, which is then associated with creating a more organized, better web overall.

    Start your headless eCommerce
    now.
    Find out More

    How to write JSON-LD?

    JSON-LD is recommended to be written in <head> tag but it can be used also written in <body> tag. It is written in between script tag having the type defined as application/ld+json. Don’t forget to add curly braces.

    <script type="application/ld+json">
    {
    .
    .
    .
    }
    </script>

    @context: It defines the settings of an idea in whose term it can be understood.

    "@context": "http://schema.org",

    @type: It defines the item type that has been marked up.

    "@Type": "…",

    Attribute-Value pairs: Next item which comes into a role on JSON-LD is attribute value pair that is item property and its value.

    Let’s write the JSON-LD for above-taken example of Hotel in India.

    <script type="application/ld+json">
    {
      "@context": "http://schema.org",
      "@type": "Hotel",
      "name" : "ABC Hotel",
      "description" : "Lorem Ipsum is simply dummy text of 
                       the printing and typesetting industry.
                       Lorem Ipsum has been the industry's standard
                       dummy text ever since the 1500s, when an unknown 
                       printer took a galley of type and scrambled it 
                       to make a type specimen book.",
      "address" : { "@type" : "PostalAddress",
                   "addressCountry" : "IN",
                   "addressLocality" : "Noida",
                   "addressRegion" : "UP",
                   "postalCode" : "201301",
                   "streetAddress" : "XYZ"
                   },
      "telephone" :  "+91 96504 86699",
      "photo" : "http://www.xyz/image.png",
      "starRating" : { "@type" : "Rating",
                       "ratingValue" : "4"},
      "priceRange" : "1000 - 2400"
    }
    </script>

    In context, we are defining the vocabulary which we are using. @type defines the item type which is the hotel. Name, description, address, telephone, photo etc are the properties of the item type that is the hotel. We can also nest item type in JSON-LD. As you can see the hotel has property address and starRating which can be of different type and they have their own attribute value pair.

    Hope this blog will help you to understand JSON-LD in a better way.

    . . .

    Leave a Comment

    Your email address will not be published. Required fields are marked*


    Be the first to comment.

    Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home