Create a simple Jason File


Like XML files JSON file can hold data in the form of  list or list of list. If you are familiar with Python list, it can be simplified. Using your favorite text editor you can create a Jason file.

JSON file can be used to store data for static web pages or can be used to transfer data between application. Let’s look at the very simple Jason file.

"institution":
[{
"name" : "RMHS MELATTUR",
"location" : "Melattur",
"catagory":"School",
"landmark":"Opp. GOVT. Hospital PMNA",
"distance":"12.km",
"Office phone":"947854545",
"district" :"Malappuram",
"web" :"http://rmhs.com",
"email" :"rmhs@outlook.com",
"course_offering" :["Plus Comp. Science","Plus Science"]
}]

In the above example we have a list called institution, and lots of keys and values, say location is a key and Melattur is the key value, you can identify the value with the key.  Each key is separated with a ‘.’ operator. and you can also have sub list which can be included within a ‘[‘ and ‘]’.

Can I hold more than one information in a Jason? yes. In the following format, within the same list.

{
"institutions":
[{
"name" : "RMHS MELATTUR",
"location" : "Melattur",
"catagory":"School",
"landmark":"Opp. GOVT. Hospital PMNA",
"distance":"12.km",
"Office phone":"947854545",
"district" :"Malappuram",
"web" :"http://rmhs.com",
"email" :"rmhs@outlook.com",
"course_offering" :["Plus Comp. Science","Plus Science"]
},
{
"name" : "NSS School",
"location" : "Manjeri",
"catagory":"School",
"landmark":"Opp. Municipality",
"distance":"12.km",
"Office phone":"947854545",
"district" :"Malappuram",
"web" :"http://rmhs.com",
"email" :"rmhs@outlook.com",
"course_offering" :["Plus Comp. Science","Plus Science"]
},
{
"name" : "MODEL School",
"location" : "Pandikkad",
"catagory":"School",
"landmark":"Opp.Buss stand",
"distance":"12.km",
"Office phone":"947854545",
"district" :"Malappuram",
"web" :"http://rmhs.com",
"email" :"rmhs@outlook.com",
"course_offering" :["Plus One Comp. Science","Plus One Science"]
},
{
"name" : "CENTRAL SCHOOL",
"location" : "Perinthelmanna",
"catagory":"School",
"landmark":"Opp. GOVT. Hospital PMNA",
"distance":"12.km",
"Office phone":"947854545",
"district" :"Malappuram",
"web" :"http://rmhs.com",
"email" :"rmhs@outlook.com",
"course_offering" :["Plus One Comp. Science","Plus One Science"]
},
{
"name" : "NSS COLLAGE",
"location" : "Palakkad",
"catagory":"Collage",
"landmark":"Opp. GOVT. Hospital PMNA",
"distance":"12.km",
"Office phone":"947854545",
"district" :"Palakkad",
"web" :"http://rmhs.com",
"email" :"rmhs@outlook.com",
"course_offering" :["BSc Comp. Science","BSc Physics,BSc Maths"]
},
{
"name" : "MES BED COLLAGE",
"location" : "Edathanattukara",
"catagory":"Collage",
"landmark":"Opp. GOVT. Hospital PMNA",
"distance":"12.km",
"Office phone":"947854545",
"district" :"Malappuram",
"web" :"http://rmhs.com",
"email" :"rmhs@outlook.com",
"course_offering" :["SS,MALAYALAM,ENGLISH"]
}
 ]
}

The file extension must be.json.

In the next post, we will learn how to read a Jason file in Python.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.