How can i import my JSON formatted data from my API to my docDB?
Hello everyone,
i want to create an iris document database with Atelier with some properties, where i can import my JSON formatted data from an API to the database which i created. Right now i know how to import my local JSON formatted data to my created database:
Class User.Classtest
{
ClassMethod getFile() as %Status
{
set filename = "/home/student/Downloads/own_scrobble.json"
IF $SYSTEM.DocDB.Exists("db.Streamingdatabase") {
SET db = ##class(%DocDB.Database).%GetDatabase("db.Streamingdatabase")
}
ELSE {
SET db = ##class(%DocDB.Database).%CreateDatabase("db.Streamingdatabase")
}
DO db.%CreateProperty("Name","%String","$.name")
DO db.%CreateProperty("Duration","%Integer","$.duration")
DO db.%CreateProperty("Playcount","%Integer","$.playcount")
DO db.%CreateProperty("Mbid","%String","$.mbid")
DO db.%CreateProperty("Url","%String","$.url")
DO db.%CreateProperty("StreamableText","%Integer","$.streamable/#text")
DO db.%CreateProperty("StreamableFulltrack","%Integer","$.streamable/fulltrack")
DO db.%CreateProperty("ArtistName","%Integer","$.artist/name")
DO db.%CreateProperty("ArtistMbid","%String","$.artist/mbid")
DO db.%CreateProperty("ArtistURL","%String","$.artist/url")
DO db.%CreateProperty("Rank","%Integer","$.@attr/rank")
set arr = ##class(%DynamicAbstractObject).%FromJSON(filename)
SET jstring = arr.%ToJSON()
DO db.%FromJSON(jstring)
}
}
Now i want to take my JSON formatted data from my API (http://ws.audioscrobbler.com/2.0/?method=chart.gettopartists&api_key=652...) instead of my local json data(own_scrobble.json) but i don't know how to take the URL from my API as my datasource. Can you guys help me?
Best regards,
Duc Anh