All Projects → maciejhirsz → Json Rust

maciejhirsz / Json Rust

Licence: other
JSON implementation in Rust

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Json Rust

Enmime
MIME mail encoding and decoding package for Go
Stars: ✭ 246 (-37.72%)
Mutual labels:  parser, decoder, encoder
Gojay
fastest JSON encoder/decoder with powerful stream API for Golang
Stars: ✭ 2,009 (+408.61%)
Mutual labels:  json, decoder, encoder
Ultrajson
Ultra fast JSON decoder and encoder written in C with Python bindings
Stars: ✭ 3,504 (+787.09%)
Mutual labels:  json, decoder, encoder
Ffmpegcommand
FFmpegCommand适用于Android的FFmpeg命令库,实现了对音视频相关的处理,能够快速的处理音视频,大概功能包括:音视频剪切,音视频转码,音视频解码原始数据,音视频编码,视频转图片或gif,视频添加水印,多画面拼接,音频混音,视频亮度和对比度,音频淡入和淡出效果等
Stars: ✭ 394 (-0.25%)
Mutual labels:  decoder, encoder
Streaming Json Encoder
PHP library for iteratively encoding large JSON documents piece by piece
Stars: ✭ 260 (-34.18%)
Mutual labels:  json, encoder
Flask Session Cookie Manager
🍪 Flask Session Cookie Decoder/Encoder
Stars: ✭ 257 (-34.94%)
Mutual labels:  decoder, encoder
morse-pro
Library for manipulating Morse code text and sound. Understands prosigns and Farnsworth speed. Can create WAV files and analyse input from the microphone or audio files.
Stars: ✭ 85 (-78.48%)
Mutual labels:  encoder, decoder
Jpegsnoop
JPEGsnoop: JPEG decoder and detailed analysis
Stars: ✭ 282 (-28.61%)
Mutual labels:  parser, decoder
Keras Transformer
Transformer implemented in Keras
Stars: ✭ 273 (-30.89%)
Mutual labels:  decoder, encoder
Ikigajson
A high performance JSON library in Swift
Stars: ✭ 302 (-23.54%)
Mutual labels:  json, encoder
Stream Parser
⚡ PHP7 / Laravel Multi-format Streaming Parser
Stars: ✭ 391 (-1.01%)
Mutual labels:  json, parser
IkigaJSON
A high performance JSON library in Swift
Stars: ✭ 316 (-20%)
Mutual labels:  encoder, decoder
AnimatedGif
📼 A high performance .NET library for reading and creating animated GIFs
Stars: ✭ 106 (-73.16%)
Mutual labels:  encoder, decoder
He
A robust HTML entity encoder/decoder written in JavaScript.
Stars: ✭ 2,973 (+652.66%)
Mutual labels:  decoder, encoder
schifra
C++ Reed Solomon Error Correcting Library https://www.schifra.com
Stars: ✭ 28 (-92.91%)
Mutual labels:  encoder, decoder
Ojg
Optimized JSON for Go
Stars: ✭ 281 (-28.86%)
Mutual labels:  json, parser
Tiny Utf8
Unicode (UTF-8) capable std::string
Stars: ✭ 322 (-18.48%)
Mutual labels:  decoder, encoder
Bad json parsers
Exposing problems in json parsers of several programming languages.
Stars: ✭ 351 (-11.14%)
Mutual labels:  json, parser
aiff
Battle tested aiff decoder/encoder
Stars: ✭ 20 (-94.94%)
Mutual labels:  encoder, decoder
android-opus-codec
Implementation of Opus encoder and decoder in C++ for android with JNI
Stars: ✭ 44 (-88.86%)
Mutual labels:  encoder, decoder

json-rust

Parse and serialize JSON with ease.

Changelog - Complete Documentation - Cargo - Repository

Why?

JSON is a very loose format where anything goes - arrays can hold mixed types, object keys can change types between API calls or not include some keys under some conditions. Mapping that to idiomatic Rust structs introduces friction.

This crate intends to avoid that friction.

let parsed = json::parse(r#"

{
    "code": 200,
    "success": true,
    "payload": {
        "features": [
            "awesome",
            "easyAPI",
            "lowLearningCurve"
        ]
    }
}

"#).unwrap();

let instantiated = object!{
    // quotes on keys are optional
    "code": 200,
    success: true,
    payload: {
        features: [
            "awesome",
            "easyAPI",
            "lowLearningCurve"
        ]
    }
};

assert_eq!(parsed, instantiated);

First class citizen

Using macros and indexing, it's easy to work with the data.

let mut data = object!{
    foo: false,
    bar: null,
    answer: 42,
    list: [null, "world", true]
};

// Partial equality is implemented for most raw types:
assert!(data["foo"] == false);

// And it's type aware, `null` and `false` are different values:
assert!(data["bar"] != false);

// But you can use any Rust number types:
assert!(data["answer"] == 42);
assert!(data["answer"] == 42.0);
assert!(data["answer"] == 42isize);

// Access nested structures, arrays and objects:
assert!(data["list"][0].is_null());
assert!(data["list"][1] == "world");
assert!(data["list"][2] == true);

// Error resilient - accessing properties that don't exist yield null:
assert!(data["this"]["does"]["not"]["exist"].is_null());

// Mutate by assigning:
data["list"][0] = "Hello".into();

// Use the `dump` method to serialize the data:
assert_eq!(data.dump(), r#"{"foo":false,"bar":null,"answer":42,"list":["Hello","world",true]}"#);

// Or pretty print it out:
println!("{:#}", data);

Installation

Just add it to your Cargo.toml file:

[dependencies]
json = "*"

Then import it in your main.rs / lib.rs file:

#[macro_use]
extern crate json;

Performance and Conformance

There used to be a statement here saying that performance is not the main goal of this crate. It is definitely one of them now.

While this crate doesn't provide a way to parse JSON to native Rust structs, it does a lot to optimize its performance for DOM parsing, stringifying and manipulation. It does very well in benchmarks, in some cases it can even outperform parsing to structs.

This crate implements the standard according to the RFC 7159 and ECMA-404 documents. For the best interoperability numbers are treated stored as 64bit precision mantissa with 16 bit decimal exponent for floating point representation.

License

This crate is distributed under the terms of both the MIT license and the Apache License (Version 2.0). Choose whichever one works best for you.

See LICENSE-APACHE and LICENSE-MIT for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].