# Write and read json file

**URL:** <https://discourse.julialang.org/t/write-and-read-json-file/97379>\
**Category:** General Usage\
**Tags:** json, read, write\
**Created:** [April 12, 2023, 6:34am UTC](https://discourse.julialang.org/t/write-and-read-json-file/97379 "2023-04-12T06:34:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rocco\_sprmnt21](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rocco_sprmnt21/32/20127_2.png) [@rocco\_sprmnt21](https://discourse.julialang.org/u/rocco_sprmnt21)\
**Post date:** [April 12, 2023, 6:34am UTC](https://discourse.julialang.org/t/write-and-read-json-file/97379/1 "2023-04-12T06:34:57Z")

</div>

I tried to save and read the following json file, but there is some problem for the presence of nothing.

```julia
using YFinance, JSON3
aapl_json=get_quoteSummary("AAPL")

aapl_json_string=string(aapl_json)
open("aapl.json", "w") do f
     write(f, aapl_json_string)
end

aapl_json_string=open("aapl.json", "r") do f
   read(f,String)
end

julia> aapl_json = JSON3.read(aapl_json_string);
ERROR: ArgumentError: invalid JSON at byte position 4217 while parsing type Nothing: InvalidChar
                  "fmt": nothing,

```

What is the correct way to save to be able to reload the file in these cases?

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [April 12, 2023, 6:56am UTC](https://discourse.julialang.org/t/write-and-read-json-file/97379/2 "2023-04-12T06:56:32Z")

</div>

```julia
julia> using YFinance, JSON3
julia> aapl_json=get_quoteSummary("AAPL")

julia> open("aapl.json", "w") do f
            JSON3.write(f, aapl_json)
       end

julia> aapl_json_in=open("aapl.json", "r") do f
          JSON3.read(f)
       end

```
