Extracting specific data from a json file

Asked 1 years ago, Updated 1 years ago, 42 views

"apistats": { "2512": { "FindFirstFileExW": 7, "NtAllocateVirtualMemory": 26, "SetFilePointer": 4, "NtCreateFile": 92, "GetFileType": 27, "NtReadFile": 29, "GetFileInformationByHandle": 19, "RegOpenKeyExA": 14, "GetFileAttributesW": 26, "NtFreeVirtualMemory": 2, "NtClose": 19 } }, },

I can't put all the contents of the json file here, so only api people like FindFirstFileExW in the above part I want to extract it and extract it, but what python code should I write? Please help me ㅠ<

python json

2022-09-22 15:58

1 Answers

{
"apistats": {
            "2512": {
                "FindFirstFileExW": 7, 
                "NtAllocateVirtualMemory": 26, 
                "SetFilePointer": 4, 
                "NtCreateFile": 92, 
                "GetFileType": 27, 
                "NtReadFile": 29, 
                "GetFileInformationByHandle": 19, 
                "RegOpenKeyExA": 14, 
                "GetFileAttributesW": 26, 
                "NtFreeVirtualMemory": 2, 
                "NtClose": 19
        }
    } 
}
import json

with open('sample.json', 'r') as f:
    content = json.load(f)

api_list = [ x for x in content['apistats']['2512'].keys()]

print(api_list)

Try it this way.


2022-09-22 15:58

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.