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
CodePudding user response:
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'}]}