# Is there a good tutorial for using JSON in Julia?

**URL:** https://discourse.julialang.org/t/is-there-a-good-tutorial-for-using-json-in-julia/103356
**Category:** New to Julia
**Created:** [August 30, 2023, 9:41am UTC](https://discourse.julialang.org/t/is-there-a-good-tutorial-for-using-json-in-julia/103356 "2023-08-30T09:41:58Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)
#### Post date: [August 30, 2023, 9:41am UTC](https://discourse.julialang.org/t/is-there-a-good-tutorial-for-using-json-in-julia/103356/1 "2023-08-30T09:41:58Z")

</div>

Hello,  
I am starting to learn how to use JSON in Julia. I can create a json object, for sinatcne:

```julia
jsJ = JSON.json(Dict("name"=>["Paul", "Peter", "Jude", "Mark"],
    "level"=>[1, 10, 20, 30],
    "code"=>["Pa", "Pe", "Ju", "Mk"]))
# write to file
open("file.json", "w") do j
    write(j, jsJ)
end

```

Is there a good tutorial on how to use JSON from here? such as reading the first elements of the dictionary (as to get: Paul, 1, Pa) and appending elements to the object?  
There is, of course, the link to the [official distribution](https://github.com/JuliaIO/JSON.jl); is there something more simplified?  
Thank you

---

<div class="post-metadata">

### Author: ![Tomas\_Pevny](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomas_pevny/32/25466_2.png) [@Tomas\_Pevny](https://discourse.julialang.org/u/Tomas_Pevny)
#### Post date: [August 30, 2023, 10:39am UTC](https://discourse.julialang.org/t/is-there-a-good-tutorial-for-using-json-in-julia/103356/2 "2023-08-30T10:39:29Z")

</div>

Hi Luigi,

I am not aware of any. The reason might be that JSONs are loaded into the common Julia structures like `Dict`, `Vector` and `String` or `Float64` and the tutorial would be common with tutorials of these structures. The function you ask is also very dependent on your data. You can quickly write it yourself as

```julia
julia> js = Dict("name"=>["Paul", "Peter", "Jude", "Mark"],
    "level"=>[1, 10, 20, 30],
    "code"=>["Pa", "Pe", "Ju", "Mk"])

julia> [k => first(v) for (k,v) in js]
3-element Vector{Pair{String}}:
  "name" => "Paul"
  "code" => "Pa"
 "level" => 1
```

---

<div class="post-metadata">

### Author: ![simsurace](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simsurace/32/30216_2.png) [@simsurace](https://discourse.julialang.org/u/simsurace)
#### Post date: [August 30, 2023, 11:04am UTC](https://discourse.julialang.org/t/is-there-a-good-tutorial-for-using-json-in-julia/103356/3 "2023-08-30T11:04:54Z")

</div>

[JSON3.jl](https://github.com/quinnj/JSON3.jl) has several [examples](https://quinnj.github.io/JSON3.jl/stable/#Getting-Started).

---

<div class="post-metadata">

### Author: ![Luigi\_Marongiu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/luigi_marongiu/32/7909_2.png) [@Luigi\_Marongiu](https://discourse.julialang.org/u/Luigi_Marongiu)
#### Post date: [August 30, 2023, 11:24am UTC](https://discourse.julialang.org/t/is-there-a-good-tutorial-for-using-json-in-julia/103356/4 "2023-08-30T11:24:27Z")

</div>

Thank you!
