# How to read JSON from HTML?

**URL:** <https://discourse.julialang.org/t/how-to-read-json-from-html/3664>\
**Category:** Web Stack\
**Tags:** question, web, json\
**Created:** [May 12, 2017, 12:57am UTC](https://discourse.julialang.org/t/how-to-read-json-from-html/3664 "2017-05-12T00:57:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [May 12, 2017, 12:57am UTC](https://discourse.julialang.org/t/how-to-read-json-from-html/3664/1 "2017-05-12T00:57:45Z")

</div>

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:

```julia
using Requests, JSON

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

```

---

<div class="post-metadata">

**Author:** ![musm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/musm/32/3675_2.png) [@musm](https://discourse.julialang.org/u/musm)\
**Post date:** [May 12, 2017, 1:00am UTC](https://discourse.julialang.org/t/how-to-read-json-from-html/3664/2 "2017-05-12T01:00:31Z")

</div>

> [@juliohm](#):
>
> Requests

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.

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [May 12, 2017, 1:02am UTC](https://discourse.julialang.org/t/how-to-read-json-from-html/3664/3 "2017-05-12T01:02:45Z")

</div>

@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?

---

<div class="post-metadata">

**Author:** ![musm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/musm/32/3675_2.png) [@musm](https://discourse.julialang.org/u/musm)\
**Post date:** [May 12, 2017, 1:08am UTC](https://discourse.julialang.org/t/how-to-read-json-from-html/3664/4 "2017-05-12T01:08:58Z")

</div>

> [@musm](#):
>
> HTTP.jl

I can’t predict the future but here is the original quote [HTTP/2 Support by sorpaas · Pull Request #133 · JuliaWeb/Requests.jl · GitHub](https://github.com/JuliaWeb/Requests.jl/pull/133#issuecomment-287851382)

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [May 12, 2017, 1:20am UTC](https://discourse.julialang.org/t/how-to-read-json-from-html/3664/5 "2017-05-12T01:20:07Z")

</div>

The answer with HTTP.jl:

```julia
using HTTP, JSON

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

```

---

<div class="post-metadata">

**Author:** ![miguelraz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/miguelraz/32/631_2.png) [@miguelraz](https://discourse.julialang.org/u/miguelraz)\
**Post date:** [September 8, 2017, 10:33pm UTC](https://discourse.julialang.org/t/how-to-read-json-from-html/3664/6 "2017-09-08T22:33:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![juliohm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juliohm/32/215266_2.png) [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Post date:** [September 8, 2017, 10:56pm UTC](https://discourse.julialang.org/t/how-to-read-json-from-html/3664/7 "2017-09-08T22:56:56Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![fengyang.wang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fengyang.wang/32/104_2.png) [@fengyang.wang](https://discourse.julialang.org/u/fengyang.wang)\
**Post date:** [September 9, 2017, 2:43am UTC](https://discourse.julialang.org/t/how-to-read-json-from-html/3664/8 "2017-09-09T02:43:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![moljac](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/moljac/32/18506_2.png) [@moljac](https://discourse.julialang.org/u/moljac)\
**Post date:** [October 8, 2020, 10:20am UTC](https://discourse.julialang.org/t/how-to-read-json-from-html/3664/9 "2020-10-08T10:20:03Z")

</div>

I am new to julia and came here searching for HTTP scraping…

This is our minimal sample (working as of 20201008):

```julia
import Pkg; 
Pkg.add("HTTP")
Pkg.add("JSON")
Pkg.add("JSON")
Pkg.add("JSON3")
Pkg.add("LazyJSON")

import HTTP
import JSON
import JSON;
import JSON3;
import LazyJSON;

using JSON
using HTTP
using JSON;
using JSON3;
using LazyJSON;

# tags
# https://api.github.com/repos/xamarin/AndroidX/tags
# https://api.github.com/repos/xamarin/Essentials/tags
# releases
# https://api.github.com/repos/xamarin/AndroidX/releases
# https://api.github.com/repos/xamarin/Essentials/releases

url = "https://raw.githubusercontent.com/xamarin/AndroidX/20200915-mono.cecil-fix/config.json"
resp = HTTP.get(url)

str = String(resp.body)
println("str = ", str)

jobj_JSON = JSON.parse(str)
println("jobj_JSON = ", jobj_JSON)

jobj_JSON3 = JSON3.read(str)
println("jobj_JSON3 = ", jobj_JSON)

jobj_LazyJSON = LazyJSON.value(str)
println("jobj_LazyJSON = ", jobj_LazyJSON)

```
