title: How to add an element to a specific position in json object using python
body: <p>I want to add new element to json object to specific index/position.</p>
  
  <p>if I use <code>data["country"] = "value"</code>, it is adding to the end of the json object.</p>
  
  <pre><code>import json
  
  data = json.loads('''{"user_name": "xcv","password": "dsjvwebv","age":27,"address":{"country_name": "value",
                    "state_name":"tamil nadu",  "district" :"Tirunelveli"    },"work_history": [      {"name": "CSC", 
                    "location": "chennai"},      {"name": "Saturam", "location": "bangalore"},      {"name": "crayon", 
                    "location": "chennai"}    ],"marital_status" :"married","disability":"No"}''')
  del data["password"]
  country = data["address"]["country_name"]
  data.pop("disability")
  data.pop("address")
  data["country"] = country
  i=0
  for j in data["work_history"]:
      if j["location"] != "chennai":
          data["work_history"].pop(i)
      i = i+1
  
  print(data)
  </code></pre>
  
  <p>i want the country value to be at position as in the output below.</p>
  
  <pre><code>{'user_name': 'xcv', 'age': 27, 'country': 'value', 'work_history': [{'name': 'CSC', 'location': 'chennai'}, {'name': 'crayon', 'location': 'chennai'}], 'marital_status': 'married}
  </code></pre>