Hello -- Is there a way to load a JSON from a file. I have a "JSON" file which has a sting 1035164 long with the following format:
[
{
"id": "12345",
"title": "John Smith",
"image_uri": "https://<some URL>",
"image_timestamp": "1496781334",
"image_url":"https://<some URL>",
"is_restricted_under_18_only": false,
"is_restricted_adult_only": false
},
...
{
"id": "67890",
"title": "Mary Jane",
"image_uri": "https://<some URL>",
"image_timestamp": "1496781334",
"image_url": "https://<some URL>",
"is_restricted_under_18_only": false,
"is_restricted_adult_only": false
}
]
There are ~ 4839 entries.
**Is it possible to parse a JSON string by loading a from a file?**
I tried this...
S filename="/tmp/pictures.json"
S stream=##class(%Stream.FileCharacter).%New()
S sc=stream.LinkToFile(filename)
I ('sc) W "Error on linking file "_filename,! W
try {
set obj=##class(%DynamicAbstractObject).%FromJSON(stream)
} catch ex {
w "Error. Unable to parse file "_filename,!
w "Error type "_ex.Name,!
w "Error code "_ex.Code,!
w "Error location "_ex.Location,!
set obj=""
}
q obj
Q
... but I get the following error:
Error. Unable to parse file /epicdc/data/pictures.json