I am using requests.get to get an output.[{"id": "e644b06c-8f5b-4bdf-84a0-7266dffc6979", "securityResourceId": "e48e8536-02ff-424d-856a-dab30af23919", "name": "helloWorld", So in the name tag i need to search if it contains xyz and if it does append that name to an array.If you could help id be obliged.Thanks
2 Answers
you can parse JSON into dictionary using json library.
after that you can search the contents with either re or fuzzywuzzy to get matching pattern.
snippet:
import json, re
input_string = '[{"test":"something"},{"xyz":"something else","foo":"bar"}]'
obj = json.loads(input_string)
arr = []
for item in obj:
for key in item:
match = re.match("xyz",key)
if match is not None:
arr.append(item)
continue