Package: jsonparse
jsonparse: ctrl-f for jsonjsonparseis a simple JSON parsing library. Extract what's needed from key:value pairs.What's NewCLI tool. Parse json text files or stdin via the command line :tada:New public (or hostable)web APIPython LibraryInstallpipinstalljsonparseQuickstartHere is a quick example of what jsonparse is able to do.fromjsonparseimportfind_key,find_keys,find_key_chain,find_key_valuedata=[{"key0":{"key1":"result","key2":{"key1":"result1","key3":{"key1":"result2"}}}}]find_key(data,'key1')['result2','result1','result']find_key_chain(data,['key0','key2','key3','key1'])['result2']:heavy_plus_sign: See additional documentation in theAPI sectionbelow.CLI toolInstallpipinstalljsonparseQuickstartSummary of cli commands. For complete information,jp --helpNote,jsonparseandjpare equivalent.jp key key1 --file text.jsonjp keys key1 key2 key3 --file text.jsonjp key-chain my '*' chain --file text.jsonjp key-value key1 '"result"' --file text.jsonecho '{"key1": {"key2": 5}}' | jp key key2APIParser classfind_keyfind_keysfind_key_chainfind_key_valueThe API examples using the following test data.data=[{"key":1},{"key":2},{"my":{"key":{"chain":"A","rope":5,"string":1.2,"cable":False}}},{"your":{"key":{"chain":"B","rope":7,"string":0.7,"cable":True}}}]ParserParser(stack_trace: bool = False,queue_trace: bool = False)Optionally instantiate theParserclass with tracing to print out the underlying data structures.p=Parser(stack_trace=True,queue_trace=True)find_keyfind_key(data: dict | list,key: str)-> listWill return all values of the matched key.p.find_key(data,'chain')['A','B']p.find_key(data,'key')[1,2,{'chain':'A','rope':5,'string':1.2,'cable':False},{'chain':'B','rope':7,'string':0.7,'cable':True}]find_keysfind_keys(data: dict | list,keys: list,group: bool = True)-> listThe default return value is a two dimensional list.[ [], [], ...].To return all values as a one dimensional list, setgroup=False.The ordering of the keys does not matter.p.find_keys(data,['rope','cable'])[[5,False],[7,True]]p.find_keys(data,['rope','cable'],group=False)[5,False,7,True]find_key_chainfind_key_chain(data: dict | list,keys: list)-> listThe key chain is an ordered list of keys. The chain needs to start at the root level of the nested data.Wildcard*can be used as key(s) to match any.p.find_key_chain(data,['my','key','chain'])['A']p.find_key_chain(data,['key'])[1,2]p.find_key_chain(data,['*','key','chain'])['A','B']p.find_key_chain(data,['*','key','*'])['A',5,1.2,False,'B',7,0.7,True]find_key_valuefind_key_value(data: dict | list,key: str,value: str | int | float | bool | None) -> listThe returned list contains the dictionaries that contain the specified key:value pair.p.find_key_value(data,'cable',False)[{'chain':'A','rope':5,'string':1.2,'cable':False}]p.find_key_value(data,'chain','B')[{'chain':'B','rope':7,'string':0.7,'cable':True}]Web APIDocumentationVisitthe swagger API documentationAll endpoints are HTTP POST requests where you include the searchable JSON data in the request body.Brief Endpoint OveriewPOST/v1/key/{key}POST/v1/keys?key=1&key=2&key=3&key=4...
POST/v1/keychain?key=1&key=2&key=3&key=4...
POST/v1/keyvalue?key=a&value=1QuickstartLet's practice using the public, free-to-use-no-authentication, web API hosted in GCP Cloud Run.We are POST'ing the JSON data with curl, requesting to search for the key, 'key1'. The found key values are returned as JSON.curl-XPOST"https://jsonparse.dev/v1/key/key1"\-H'Content-Type: application/json'\-d'[{"key0":{"key1":"result","key2":{"key1":"result1","key3":{"key1":"result2"}}}}]'["result2","result1","result"]OR (using python and requests library)importrequestsdata=[{"key0":{"key1":"result","key2":{"key1":"result1","key3":{"key1":"result2"}}}}]requests.post('https://jsonparse.dev/v1/key/key1',json=data).json()['result2','result1','result']Self-Hostedpipinstall"jsonparse[webapi]"gunicorn-b0.0.0.0:8000jsonparse.webapi:appAlternatively, run the docker containerdockerrun-dctomkow/jsonparse