95 releases (breaking)

Uses new Rust 2024

0.110.0 Jan 18, 2026
0.109.1 Dec 2, 2025
0.109.0 Nov 29, 2025
0.106.1 Jul 29, 2025
0.23.0 Nov 24, 2020

#162 in Encoding

Download history 4354/week @ 2025-10-14 4273/week @ 2025-10-21 5441/week @ 2025-10-28 5494/week @ 2025-11-04 4407/week @ 2025-11-11 3370/week @ 2025-11-18 3744/week @ 2025-11-25 4801/week @ 2025-12-02 5094/week @ 2025-12-09 5146/week @ 2025-12-16 2093/week @ 2025-12-23 2883/week @ 2025-12-30 4688/week @ 2026-01-06 4701/week @ 2026-01-13 5071/week @ 2026-01-20 4811/week @ 2026-01-27

20,366 downloads per month
Used in 40 crates (7 directly)

MIT license

230KB
5K SLoC

nu-json

crate

a fork of serde_hjson.

The changes made to this crate are kept in CHANGELOG.

The Rust implementation of Hjson is based on the Serde JSON Serialization Library.

This crate is a Rust library for parsing and generating Human JSON Hjson. It is built upon Serde, a high performance generic serialization framework.

Install

This crate works with Cargo and can be found on crates.io with a Cargo.toml like:

[dependencies]
serde = "1"
nu-json = "0.76"

From the Commandline

Add with:

 cargo add serde
 cargo add nu-json

Usage

extern crate serde;
extern crate nu_json;

use nu_json::{Map,Value};

fn main() {

    // Now let's look at decoding Hjson data

    let sample_text=r#"
    {
        ## specify rate in requests/second
        rate: 1000
        array:
        [
            foo
            bar
        ]
    }"#;

    // Decode and unwrap.
    let mut sample: Map<String, Value> = nu_json::from_str(&sample_text).unwrap();

    // scope to control lifetime of borrow
    {
        // Extract the rate
        let rate = sample.get("rate").unwrap().as_f64().unwrap();
        println!("rate: {}", rate);

        // Extract the array
        let array : &mut Vec<Value> = sample.get_mut("array").unwrap().as_array_mut().unwrap();
        println!("first: {}", array.first().unwrap());

        // Add a value
        array.push(Value::String("baz".to_string()));
    }

    // Encode to Hjson
    let sample2 = nu_json::to_string(&sample).unwrap();
    println!("Hjson:\n{}", sample2);
}

DOCS

At the moment, the documentation on serde_hjson / serde_json is also relevant for nu-json.

Dependencies

~7–11MB
~210K SLoC