How to format out put as Json in flask get request

I am quite new to flask, Basically i have this code which returns multiple values length= len(data[‘hits’][‘hits’]) for i in range(length): #print(i) #print (data[‘hits’][‘hits’][i][‘_source’][‘message’]) imei=((data[‘hits’][‘hits’][i][‘_source’][‘GPS-LOG’].get(“IMEI”))) print (“imei: {}”.format(imei)) log_time=((data[‘hits’][‘hits’][i][‘_source’][‘@timestamp’])) print (“log time: {}”.format(log_time)) out put :- imei: 44444 log time: 2019-09-21T23:31:28.429Z imei: 55555 log time: 2019-09-21T23:32:02.554Z imei: 22222 log time: 2019-09-21T23:32:04.561Z imei: 555555 log time:…

Query JSONB column for any value where =?

I have a jsonb column which has the unfortunate case of being very unpredictable, in some cases its value may be an array with nested values: [“UserMailer”, “applicant_setup_3”, [“5cbffeb7-8d5e-4b52-a475-3cf320b2cee9”]] Sometimes it will be something with key/values like this: [{“reference_id”: “5cbffeb7-8d5e-4b52-a475-3cf320b2cee9”, “job_dictionary”: [“StatusUpdater”, “FollowTwitterUsersJob”]}] Is there a way to write a query which just treats the…

Reconstructing JSON with jq

I have a JSON like this (sample.json): { “sheet1”: [ { “hostname”: “sv001”, “role”: “web”, “ip1”: “172.17.0.3” }, { “hostname”: “sv002”, “role”: “web”, “ip1”: “172.17.0.4” }, { “hostname”: “sv003”, “role”: “db”, “ip1”: “172.17.0.5”, “ip2”: “172.18.0.5” } ], “sheet2”: [ { “hostname”: “sv004”, “role”: “web”, “ip1”: “172.17.0.6” }, { “hostname”: “sv005”, “role”: “db”, “ip1”: “172.17.0.7” },…