#urlencode #url #json

jsurl

A more compact and human-readable alternative to JSON + URL encoding

1 unstable release

0.1.0 Feb 27, 2024

#850 in Encoding

MIT/Apache

18KB
352 lines

jsurl

A more compact and human-readable alternative to JSON + URL encoding.

crates.io Documentation Rust CI rustc 1.0+

Dependency Status Download Status

Usage

Add this to your Cargo.toml:

[dependencies]
jsurl = "0.1"

Description

This crate is a Rust implementation of the jsurl serialization format. It is a more compact and human-readable alternative to plain URL encoding for including JSON in URLs.

Example

use jsurl::{deserialize, serialize};
use serde_json::json;

let obj = json!({
    "name": "John Doe",
    "age": 42,
    "children": ["Mary", "Bill"]
});

let serialized = serialize(&obj);
assert_eq!(serialized, "~(name~'John*20Doe~age~42~children~(~'Mary~'Bill))");

let deserialized = deserialize("~(name~'John*20Doe~age~42~children~(~'Mary~'Bill))").unwrap();
assert_eq!(deserialized, obj);

License

Dual-licensed for compatibility with the Rust project.

Licensed under the Apache License Version 2.0: http://www.apache.org/licenses/LICENSE-2.0, or the MIT license: http://opensource.org/licenses/MIT, at your option.

Dependencies

~1.1–1.7MB
~31K SLoC