【问题标题】:Julia lang - How to read JSON from HTTP URLJulia lang - 如何从 HTTP URL 读取 JSON
【发布时间】:2015-06-06 21:11:44
【问题描述】:

目标

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

【问题讨论】:

    标签: json julia http-get


    【解决方案1】:

    代码

    #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"])
    

    Git Gist

    【讨论】:

      【解决方案2】:

      替代方案,使用 HTTP(找到 here):

      using HTTP, JSON
      
      resp = HTTP.get("https://api.github.com/users/juliohm")
      str = String(resp.body)
      jobj = JSON.Parser.parse(str)
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-05-22
        • 2016-08-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-03-01
        • 2015-01-20
        • 1970-01-01
        相关资源
        最近更新 更多