https://github.com/znx3p0/ions
https://github.com/znx3p0/ions
Last synced: 23 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/znx3p0/ions
- Owner: znx3p0
- Created: 2021-03-15T08:07:22.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-23T06:52:29.000Z (about 4 years ago)
- Last Synced: 2025-04-05T01:11:11.053Z (about 2 months ago)
- Language: Rust
- Size: 23.4 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ION
```ruby
# ion(s) | intuitive object notation (ser/deser)
College MIT
Grades {
Student1 92
Student2 95
Student3 93
Student4 98
}
Classes [
History
Math
Biology
CS
Classics
]
``````rust
#[derive(Serialize, Deserialize, Debug)]
pub struct Docs {
College: String,
Grades: Grades,
Classes: Vec,
}#[derive(Serialize, Deserialize, Debug)]
pub struct Grades {
Student1: i64,
Student2: i64,
Student3: i64,
Student4: i64,
}// the current way of deserializing a struct in ion is weird since
// a deserializer hasn't been implemented yet.
// but, since ion and json are similar, ion is transpiled to json
// and can then be deserialized correctly.
// a deserializer is in progressuse std::fs::read_to_string;
use ion::ion_to_json;fn main() {
let docs = read_to_string("docs.ion").unwrap();
let docs = ion_to_json(&docs).unwrap();
println!("ion as json {}", docs);
let docs: Docs = serde_json::from_str(&docs).unwrap();
println!("{:#?}", docs);
}
```