| Crates.io | suika_json |
| lib.rs | suika_json |
| version | 0.1.5 |
| created_at | 2025-01-01 21:34:26.114601+00 |
| updated_at | 2025-06-15 22:31:18.337069+00 |
| description | A JSON handling library for the suika web stack |
| homepage | |
| repository | https://github.com/JonWatkins/suika/tree/master/crates/suika_json |
| max_upload_size | |
| id | 1501096 |
| size | 28,568 |
Important: This is a personal toy project, developed as an experiment and learning exercise.
As a toy project, its future development is uncertain. It may or may not receive future updates, maintenance, or bug fixes. Please do not use it in production environments.
Suika JSON is a JSON handling library for the Suika web stack (also a toy project). It provides basic functionality for parsing JSON strings, primarily for understanding JSON parsing concepts and for experimental purposes.
The API is subject to change. This project is not thoroughly tested or hardened for real-world applications, and documentation may be basic.
JsonValue enums.Here's an example of how to use suika_json to parse a JSON string:
use suika_json::{parse_json, JsonValue};
fn main() {
let json = r#"{ "key": "value", "array": [1, 2, 3], "number": 123.45, "boolean": true, "null": null }"#;
let value = parse_json(json).unwrap();
assert_eq!(value, JsonValue::Object(vec![
("key".to_string(), JsonValue::String("value".to_string())),
("array".to_string(), JsonValue::Array(vec![
JsonValue::Number(1.0),
JsonValue::Number(2.0),
JsonValue::Number(3.0)
])),
("number".to_string(), JsonValue::Number(123.45)),
("boolean".to_string(), JsonValue::Boolean(true)),
("null".to_string(), JsonValue::Null)
]));
}
The JsonParser struct is used to parse JSON strings into JsonValue enums. Here's an example of how to use JsonParser:
use suika_json::{JsonParser, JsonValue};
fn main() {
let mut parser = JsonParser::new(r#"{ "key": "value" }"#);
let value = parser.parse().unwrap();
assert_eq!(value, JsonValue::Object(vec![
("key".to_string(), JsonValue::String("value".to_string()))
]));
}
The JsonValue enum represents a JSON value and can be one of the following variants:
Object(Vec<(String, JsonValue)>): A JSON object represented as a vector of key-value pairs.Array(Vec<JsonValue>): A JSON array represented as a vector of JsonValue elements.String(String): A JSON string.Number(f64): A JSON number.Boolean(bool): A JSON boolean.Null: A JSON null value.