Skip to content

quinnj/JSON3.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

0x0f0f0fale
and
ale
Mar 28, 2025
fb220e5 · Mar 28, 2025
Sep 5, 2022
Feb 7, 2020
Jan 10, 2025
Dec 15, 2023
Dec 17, 2024
Dec 17, 2024
Feb 16, 2020
Jun 12, 2020
Mar 28, 2025
Mar 6, 2021

Repository files navigation

JSON3.jl

Build Status codecov

Documentation

Stable Dev

Yet another JSON package for Julia; this one is for speed and slick struct mapping

TL;DR

Basic

# builtin reading/writing
JSON3.read(json_string)
JSON3.write(x)

# custom types
JSON3.read(json_string, T; kw...)
JSON3.write(x)

More complicated

# custom types: incrementally update a mutable struct
x = T()
JSON3.read!(json_string, x; kw...)
JSON3.write(x)

# read from file
json_string = read("my.json", String)
JSON3.read(json_string)
JSON3.read(json_string, T; kw...)

# write to file
open("my.json", "w") do f
    JSON3.write(f, x)
    println(f)
end

# write a pretty file
open("my.json", "w") do f
    JSON3.pretty(f, JSON3.write(x))
    println(f)
end

# generate a type from json
using StructTypes
JSON3.@generatetypes json_string_sample
JSON3.read(json_string, JSONTypes.Root)