Julia lang - 如何从HTTP URL读取JSON

sur*_*upa 4 json http-get julia

目标

如何使用Julia-lang从HTTP URL读取JSON?

sur*_*upa 5

#Importing Requests package
Pkg.add("Requests")
using Requests.get;

import JSON;

url = "http://query.yahooapis.com/v1/public/yql?q=select%20DaysRange%20from%20yahoo.finance.quotes%20where%20symbol%20in%20%28%22EBAY%22%29%20&env=http://datatables.org/alltables.env&format=json";

#Reads the data from HTTP URL
es = get(url);

j = JSON.parse(es.data)


#Prints the data from JSON
print(j["query"]["results"]["quote"])
Run Code Online (Sandbox Code Playgroud)

Git Gist


tuc*_*son 5

或者,使用 HTTP(可在此处找到):

using HTTP, JSON

resp = HTTP.get("https://api.github.com/users/juliohm")
str = String(resp.body)
jobj = JSON.Parser.parse(str)
Run Code Online (Sandbox Code Playgroud)