Turns a JSON document into a struct for rust-lang
Project description
Turns a JSON document into a struct for rust-lang
Installation
From the project root directory:
$ python setup.py install
Or:
$ pip install json2rust
Usage
Simply run it with the name of the root struct and the path to your JSON:
$ json2rust MyStruct data.json
Use –help/-h to view info on the arguments:
$ json2rust --help
Example
Take your JSON doc:
$ cat testdata/example.json
{
"name": "Me",
"age": 33,
"children": [
{
"name": "joe",
"age": 0.5,
"exists": false
}
],
"job": {
"employer": "foo",
"salary": 5000000,
"coworker": null
}
}
Run json2rust:
$ json2rust ExampleStruct testdata/example.json
pub struct ExampleStruct {
pub job: Job,
pub age: i32,
pub name: String,
pub children: Vec<Children>,
}
pub struct Job {
pub salary: i32,
pub coworker: Option<UNKNOWN_NULL>,
pub employer: String,
}
pub struct Children {
pub age: f32,
pub name: String,
pub exists: bool,
}
Release Notes
- 0.1.0:
Project works
- 0.0.1:
Project created
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
json2rust-0.2.0.tar.gz
(3.2 kB
view details)
File details
Details for the file json2rust-0.2.0.tar.gz.
File metadata
- Download URL: json2rust-0.2.0.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ed2a70c9a820be19cbc8571ad32e0afd993b3bcb5ba7b1f0aa578434acd0242
|
|
| MD5 |
ab8a0298a68ef34c12268ef41ac855a9
|
|
| BLAKE2b-256 |
eeaf9c90b8770448a19c5eaaa4bd0a997cd27391d3953ec0affbf869639b3d35
|