I have JSON data as below:
{
"Body": {
"AccNum": [
"000405010255",
"000405010310",
"000405009777",
"000401109537",
"000401113460",
"000401116861",
"001805015288",
"628801537715",
"000319000184",
"000401193586",
"000405111139",
"000405501186",
"000760004994",
"000805015689",
"000813001320",
"001105024982",
"001801080623",
"001810042371",
"001825075268",
"004214109637",
"004214109638",
"010310000278",
"032501004151",
"044205008102",
"105701000275",
"630010075140"
]
}
}
Now i have to fetch the number one by one and hide the first 8 digits of the number and then encode the number and after encrypt the number. How can i do this part for all numbers? Like ex. first, it'll fetch the first number then it'll hide the first 8 digits of that number after it will encode the number and encrypt the number after it will fetch the second number it will process the same. for all numbers, i have to process like this.
use json module and list slicing. you are basically concatenating X 8 times with other 4 digits of your list item
import json
a={
"Body": {
"AccNum": [
"000405010255",
"000405010310",
"000405009777",
"000401109537",
"000401113460",
"000401116861",
"001805015288",
"628801537715",
"000319000184",
"000401193586",
"000405111139",
"000405501186",
"000760004994",
"000805015689",
"000813001320",
"001105024982",
"001801080623",
"001810042371",
"001825075268",
"004214109637",
"004214109638",
"010310000278",
"032501004151",
"044205008102",
"105701000275",
"630010075140"
]
}
}
a["Body"]["AccNum"]=["X"*8 + x[8:] for x in a["Body"]["AccNum"]]
print(json.dumps(a))