Feb-12-2019, 11:53 PM
(Feb-12-2019, 11:08 PM)DG1234 Wrote: My requirements how to create DICTIONARY FROM THAT TEXT/LOG FILE. We have to create data in a Dictionary form from the file.@buran dos that.
message = json.loads(json_message)After
json.load()
it's a Python dictionary.>>> type(message) <class 'dict'> >>> message {'sourceSysAcctNumber': '22222222222', 'sourceSysCode': 'TP', 'transactions': [{'AcctTypeCode': 'DD', 'BranchNumber': '000y', 'Desc': '02/05 FEDEXOFFICE 00 YYYYY', 'ProductCode': '104', 'TransCode': 'YYY'}]} >>> message['sourceSysAcctNumber'] '22222222222' # When coming from json is also normal to have list mixed into the dictionary >>> message['transactions'][0]['ProductCode'] '104'