XML/JSON

Markup refers to data included in an electronic document (e.g. ebook, webpage, *.txt file) which is distinct from the document’s content. Generally, the markup document generally represents an electronic document with end-user content. in that it is typically not included in representations of the document for end users, for example on paper or a computer screen, or in an audio stream. Markup is often used to control the display of the document or to enrich its content to facilitate automated processing.

markup language (e.g. HTML, XML) is a set of rules governing what markup information may be included in a document and how it is combined with the content of the document in a way to facilitate use by humans and computer programs. Usually represented in <>

The idea and terminology evolved from the “marking up” of paper manuscripts (i.e., the revision instructions by editors), which is traditionally written with a red pen or blue pencil on authors’ manuscripts.

JSON

{key:value}

{"key":[
    {"array value"},
    {"array value"}
]}

Some examples:

{“name”:”Lin”}

{“name”:”Lin”, “age”:29, “home”:”New York City”}

{"teachers":[
    {"name":"Lin", "age":29, "home":"New York City"},
    {"name":"Joe", "age":39, "home":"Tokyo"}
]}

Use JSONLint to validate JSON

JSON parser helps to interpret JSON

Python

JSON file (jsontest.json) contents:

{  
    "leader": {  
        "title": "King",   
        "age": 100,   
        "designation": "royalty"
    }  
}  

Python code:

import json

# load JSON file for Python use
with open('<path_to_JSON_file>\jsontest.json') as filex:
    jsonvar = json.load(filex)

print(jsonvar)
print(jsonvar["leader"]["designation"])

output:

{'leader': {'title': 'King', 'age': 100, 'designation': 'royalty'}}
royalty

Reference

  1. Markup language. (2001, March 23). Wikipedia, the free encyclopedia. Retrieved May 26, 2022, from https://en.wikipedia.org/wiki/Markup_language