Is it possible to download a json file from an http:// address?

ruimac

Member
I was trying to use the Data Reader, to read a json file into a Text container but the json files contain accented characters (like é, à, ã, ô or ç) and the Data Reader strips those characters.
So, is there any way to use Viz Script to load a json file from the internet to dump it into a string?
 
You can use this function:
Code:
function GetDataFromUrl(URL as String, server as String, port as integer) as string
    dim data as String
    dim xmlLoadString = "GET " & URL & " HTTP/1.0\n"
    xmlLoadString &= "Host: " & server & "\n"
    xmlLoadString &="\n\n\r\n\0"
    data = System.TcpSend(server, port, xmlLoadString, 10000)
    ' look for the start of the JSON data
    dim startIndex = data.find("{")
    if (startIndex == -1) then
        startIndex = data.find("[")
    end if
    data.erase(0,startIndex-1)
    GetDataFromUrl = data
end function

Or if you want to go the extra mile you can try using the attached json parser
 

Attachments

  • JsonParser.zip
    7 KB · Views: 16
Back
Top