Closed Kangz closed 4 years ago
Thanks for bringing this up. Can you tell me what tool you used to check the validity of that JSON. I tested with VSCode and and online editor, and for both this was valid JSON and neither of them breaks like in the snippet you posted. The JSON Linter at https://jsonlint.com/ also reports this as a valid JSON file.
I was using the following in Python:
import json
json.loads(the_report)
Looking at the JSON spec, newline aren't allowed in strings but it seems most tools accept it? Feel free to close as won't fix if you want.
Using e.g. python to consume the API was one of the reasons for writing it, so I'd like to fix this ;)
I just checked with python 3 and it loads fine for me with json.loads and I don't get any new lines in the string.
Are you using python 2?
Sorry my mistake, I improperly decoded the file. It properly contains "\n" and not newline. Sorry for the noise.
For example https://vulkan.gpuinfo.org/api/v2/devsim/getreport.php?id=8483 contains the following:
Which is invalid JSON produced because the comma always adds a newline, even when inside quotes.