0

Main Json file

{
 "Section": [
    {
      "Update": "Y",
      "header": "Revision History",
      "setitle": " Table A",
      "subtitle": "Region 101",
      "Table": "RegionCode101",
      "Action": "InsertRegion",
      "B": "1.0.0.9.3",
      "S": "1.0.0.8",
      "C": "1.0.0.1",
      "T": "1.0.0.3",
      "I": "0.0.0.300",
      "IN": "0.0.1.491",
      "IPNB": "0.0.2.398",
      "CH": "0.0.1.258",
      "CNP": "0.0.1.491",
      "CBL": "0.0.1.4"
    },
{
          "Update": "Y",
          "header": "Revision History",
          "setitle": " Table A",
          "subtitle": "Region 101",
          "Table": "RegionCode101",
          "Action": "InsertRegion",
          "B": "1.0.0.9.3",
          "S": "1.0.0.8",
          "C": "1.0.0.1",
          "T": "1.0.0.3",
          "I": "0.0.0.300",
          "IN": "0.0.1.491",
          "IPNB": "0.0.2.398",
          "CH": "0.0.1.258",
          "CNP": "0.0.1.491",
          "CBL": "0.0.1.4"
        }

}

Above is main json file where I want to update values for "B","S","C","T","I" to be take from below file

["B": "3.11.0.904.175","S": "3.11.0.183","C": "3.11.0.029","T: 3.11.0.007"].

Want to see updated main json file as below

{
 "Section": [
    {
      "Update": "Y",
      "header": "Revision History",
      "setitle": " Table A",
      "subtitle": "Region 101",
      "Table": "RegionCode101",
      "Action": "InsertRegion",
      "B": "3.11.0.904.175",
      "S": "3.11.0.183",
      "C": "3.11.0.029",
      "T": "3.11.0.007",
      "I": "0.0.0.300",
      "IN": "0.0.1.491",
      "IPNB": "0.0.2.398",
      "CH": "0.0.1.258",
      "CNP": "0.0.1.491",
      "CBL": "0.0.1.4"
    },
{
          "Update": "Y",
          "header": "Revision History",
          "setitle": " Table A",
          "subtitle": "Region 101",
          "Table": "RegionCode101",
          "Action": "InsertRegion",
          "B": "3.11.0.904.175",
          "S": "3.11.0.183",
          "C": "3.11.0.029",
          "T": "3.11.0.007",
          "I": "0.0.0.300",
          "IN": "0.0.1.491",
          "IPNB": "0.0.2.398",
          "CH": "0.0.1.258",
          "CNP": "0.0.1.491",
          "CBL": "0.0.1.4"
        }

}

Looking to update multiple values in both sections as per above output

1 Answer 1

1
check = {
 "Section": [
    {
      "Update": "Y",
      "header": "Revision History",
      "setitle": " Table A",
      "subtitle": "Region 101",
      "Table": "RegionCode101",
      "Action": "InsertRegion",
      "B": "1.0.0.9.3",
      "S": "1.0.0.8",
      "C": "1.0.0.1",
      "T": "1.0.0.3",
      "I": "0.0.0.300",
      "IN": "0.0.1.491",
      "IPNB": "0.0.2.398",
      "CH": "0.0.1.258",
      "CNP": "0.0.1.491",
      "CBL": "0.0.1.4"
    },
 ]
}
     
check['Section'][0]['B'] = "3.11.0.904.175"
check['Section'][0]['S'] = "3.11.0.183"
check['Section'][0]['C'] = "3.11.0.029"
check['Section'][0]['T'] = "3.11.0.007"

check

output is

{'Section': [{'Update': 'Y',
   'header': 'Revision History',
   'setitle': ' Table A',
   'subtitle': 'Region 101',
   'Table': 'RegionCode101',
   'Action': 'InsertRegion',
   'B': '3.11.0.904.175',
   'S': '3.11.0.183',
   'C': '3.11.0.029',
   'T': '3.11.0.007',
   'I': '0.0.0.300',
   'IN': '0.0.1.491',
   'IPNB': '0.0.2.398',
   'CH': '0.0.1.258',
   'CNP': '0.0.1.491',
   'CBL': '0.0.1.4'}]}
Sign up to request clarification or add additional context in comments.

2 Comments

How can i use it to update multiple sections ?
with a for loop, check[Section][key] = value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.