I have some JSON data:
{
"key1":"value1",
"key2":"value2",
"HTTP Method": "POST",
"key3":{
"key3_1":"value3_1",
"key3_2":"value3_2",
"key3_3":"value3_3",
"key3_4":"value3_4",
"key3_5":"value3_5",
"key3_6":"value3_6",
"key3_7":"value3_7"
},
"key4":{
"Accept":[
"*/*"
]
}
}
I want to do two operations here:
- Removal of some nested key value pairs.
- In the nested values, I need to change some like
"value3_5"to"val****".
In the second case, I can use this logic : If s is your string and n the number of not hidden characters: s[:n] + '*' * (len(s)-n).
All I want to do is:
{
"key1":"value1",
"key2":"value2",
"httpMethod":"POST",
"key3":{
"key3_1":"value3_1",
"key3_2":"val*****",
"key3_5":"value3_5",
"key3_7":"val*****"
},
"key4":{
"Accept":[
"*/*"
]
}
}
I have removed here some nested key value pair and change the nested value to "value3_2" to "val*****" (the 2nd part was already done.)