Runtime JSON parser for Rust

crates.io travis-ci coveralls

simple_json is a JSON run-time recursive parser created for simplyfing both reading and writing JSON-encoded data. It's also supposed to be compatible with the current stable release so if you detect any problems, please report them.

Although I believe this package runs fast enough for most cases, it wasn't made with performance or big data sets in mind. In those cases you may be better using Serde instead.

This package abuses Rust's Option feature and creates a tree, where all nodes fit into one of 6 types:

All of them implement the From trait in both ways, so converting between them and their native counterparts should be as easy as calling into().

Number is another enum created to represent the multiple different types a JSON Number can hold. The parser will try to choose the most sensible type for each situation, so this should be transparent to user.

A Number can be one of 3 types:

Here's a simple example:

```rust extern crate simple_json;

use simple_json::Json;

fn main() { let mut text = "{ \"integer\": 12, \"float\": 80.5, \"string\": \"A JSON sample\", \"array\": [ 1, 2, 3 ], \"object\": { \"a\": \"b\" } }"; let result = Json::parse(text).unwrap();

println!("Result: {}", result.to_string());

} ```

Output:

rust Result: { "integer": 12, "float": 80.5, "string": "A JSON sample", "array": [ 1, 2, 3 ], "object": { "a": "b" } }