rhysd / tinyjson Goto Github PK
View Code? Open in Web Editor NEWSimple JSON parser/generator for Rust
Home Page: https://crates.io/crates/tinyjson
License: MIT License
Simple JSON parser/generator for Rust
Home Page: https://crates.io/crates/tinyjson
License: MIT License
The README documents the .query
method, which cannot be found in the latest release v2.5.1 doc.
I suppose there are some major changes in the git repo are not published yet?
Currently it is hard to access to nested elements. ([]
operator panics when the key or index doesn't exist)
We need to consider some query API to
API currently I'm thinking about:
let v: JsonValue = r#"[{"foo": true}]"#.parse().unwrap();
// Access to nested element
let found = v.query().child(0).child("foo").find();
assert_eq!(found, Some(&JsonValue::Boolean(true)));
// Check if key exists
assert!(v.query().child(0).exists());
assert!(!v.query().child(1).exists());
assert!(!v.query().child("foo").exists());
// Mutably access to nested element
let Some(found) = v.query_mut().child(0).child("foo").find() else { panic() };
*found = JsonValue::Number(10.0);
assert_eq!(v.stringify().unwrap(), "[{\"foo\":10}]");
My JSON file might not contain a certain key. How do I check if such key exists? I'd rather not resort to catching panics.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.