I have a JSON file created as response by running multiple curl statements (GET requests to a service) in parallel.
Now when I try to parse the JSON file using python it fails as the file has multiple JSONs appended
Error:
Error: Parse error on line 1: ...CT_AGGREGATE"}]}]}]}{"serviceResponseTim -----------------------^ Expecting 'EOF', '}', ',', ']', got '{'
Example in the file:
{"serviceResponseTime":510, ........... .......:[{"categoryId":28162,"metricValue":97,"days":"NONE","metricMappedType":"PRODUCT_AGGREGATE"}]}]}]}{"serviceResponseTime":387,"products":[{"productReferenceId":...................
As you see these are 2 response obtained from 2 curl statements but as I ran them in parallel using xargs, it appended the output in 1 line.
Now my problem is parsing this file.
Can anyone suggest a way to either put the output of curl commands into separate lines in the file.
Or a crude way I thought was if I could extract the part from beginning of the file till "}]}]}]}{", cut from the current file and put it into another file and run the JSON parser on that file which would have just 1 JSON o/p. Repeat this in loop till the original file is empty after we have cut out each of the JSON from it. Now my problem is I am not able to extract from beginning of line to }]}]}]}{.
Also all JSON o/ps are appended in 1 line and are not on separate lines else I would have read line by line.
Can anyone help here?