1st, you need to understand list/arrays and maps data structures, and how they are represented by JSON. Seriously, you must understand those data structures in order to use JSON.
An empty array a1
a1 = []
Array with 3 integers
a2 = [1, 2, 3]
To address the 2nd value
a2[0] is 1st value
a2[1] is 2nd value
In python, to subset a2 into 2nd and 3rd value
a3 = a2[1:]
Maps/dicts are containers of key:value pairs.
And empty map (called a dict in python)
d1 = {}
Maps with 2 pairs
d2 = { 'name' : 'Chandra Gupta Maurya' , 'age' : 2360 }
d3 = { 'street' : 'ashoka' , 'location' : 'windsor place' , 'city' : 'delhi' }
such that value of
d2['name'] is 'Chandra Gupta Maurya'
An array of two maps. When you do this in python (and javaScript)
ad1 = [ d2, d3 ]
you are equivalently doing this:
ad1 = [
{ 'name' : 'Chandra Gupta Maurya' , 'age' : 2360 } ,
{ 'street' : 'ashoka' , 'location' : 'windsor place' , 'city' : 'delhi' }
]
so that ad1[0]
is
{ 'name' : 'Chandra Gupta Maurya' , 'age' : 2360 }
Obviously "emp_details" is in position 0 of an array
json_data[0]['emp_details']
json_data[0]['emp_details']
itself is the key to an array of maps.
>>> json.dumps (json_data[0]["emp_details"] , indent=2)
produces
'[\n [\n "Shubham",\n "ksing.shubh@gmail.com",\n "intern"\n ],\n [\n "Gaurav",\n "gaurav.singh@cobol.in",\n "developer"\n ],\n [\n "Nikhil",\n "nikhil@geeksforgeeks.org",\n "Full Time"\n ]\n]'
and
>>> print ( json.dumps (json_data[0]["emp_details"], indent=2) )
produces
[
[
"Shubham",
"ksing.shubh@gmail.com",
"intern"
],
[
"Gaurav",
"gaurav.singh@cobol.in",
"developer"
],
[
"Nikhil",
"nikhil@geeksforgeeks.org",
"Full Time"
]
]
Therefore,
>>> json_data[0]["emp_details"][1]
['Gaurav', 'gaurav.singh@cobol.in', 'developer']
Then you might wish to do the replacement
>>> json_data[0]["emp_details"][1][2] = 'the rain in maine falls plainly insane'
>>> json_data[0]["emp_details"][1][1] = "I'm sure the lure in jaipur pours with furore"
>>> print ( json.dumps (json_data, indent=2) )
produces
[
{
"add": "dtlz",
"emp_details": [
[
"Shubham",
"ksing.shubh@gmail.com",
"intern"
],
[
"Gaurav",
"I'm sure the lure in jaipur pours with furore",
"the rain in maine falls plainly insane"
],
[
"Nikhil",
"nikhil@geeksforgeeks.org",
"Full Time"
]
]
}
]