How to read JSON from HTML?

question
web
json

#1

I know we can use Requests.jl to get the data, but I am not sure how we can parse the JSON with JSON.jl:

using Requests, JSON

r = get("https://api.github.com/users/juliohm")
parse(r.data) # should JSON.Parser.parse work here?

#2

I think you should probably try HTTP.jl

I don’t think Requests is recommended or actively maintained
quoting malmaud the biggest contributor

I think HTTP.jl is probably the future of the Julia we stack. Would be
awesome to get it merged there.


#3

@musm my choice for Requests.jl over HTTP.jl was based on the number of stars on GitHub (100 vs. 19), could you please confirm HTTP.jl is the future?


#4

I can’t predict the future but here is the original quote https://github.com/JuliaWeb/Requests.jl/pull/133#issuecomment-287851382


#5

The answer with HTTP.jl:

using HTTP, JSON

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

#6

@juliohm, should it be JSON.parse(str) * ?


#7

@miguelraz I don’t remember what happened, but I had to use JSON.Parser.parse(str) instead as I wrote on my answer. Maybe it has changed since then.


#8

JSON.parse should work, but will not autocomplete in the REPL due to a Julia REPL limitation.