Cannot read JSON file from URL

I would like to access the data in the json file but for some reason loadJSON() doesn’t like the url.

Any ideas? Thank you!

url = ''

let req = new Request(url);
let response = await req.loadJSON();

Given that the Scriptable output for me looks like this:

2020-11-12 12:42:25: Error: The data couldn’t be read because it isn’t in the correct format.

And in Shortcuts like this:

I’d say that the page output is probably not valid JSON.

I tried copying it directly from Safari as well as Shortcuts so that I could put it into a JSON validator, and Safari couldn’t even give me the option to copy the page content.

1 Like

Thank you for taking the time to check!

I was able to read it with Jayson. That’s why I thought I might be doing something wrong.

Well, it’s a pity I can’t read the covid data in my area then. Thank you!

If you can read it in Jayson that would suggest it is valid.

I’ve just retried it in Shortcuts and that worked. Tried it again, and it failed again.

I am beginning to think that it might simply be an unreliable API implementation.

1 Like

+1 on Jayson being good at telling JSON from would-be-JSON.

(I talk about programs that have syntax errors as eg “would-be COBOL”.) :slight_smile:

I suspect data truncation or encoding issues.