2025-01-11 11:50:00
github.com
KEON is a human readable object notation / serialization format that syntactic similar to Rust and completely supports Serde’s data model.
Cheat sheet
Unit | () |
---|---|
Booleans | true , false |
Numbers | 42 , 0x1123 , -1 , 3.14 , inf , NaN |
Chars | 'A' , '✱' , '\n' , '\u{3000}' |
Strings | "Hello" , `"raw string ^o^/"` |
Bytes | b"Hello" , b`"raw bytes ^o^/"` , b64"Sy0tQWV0aGlheA" |
Options | ? , ? Thing |
Tuples | (T,) , (T, U, V) |
Lists | ["abc", "def"] |
Maps | { 1 => 2, 3 => 4 } |
Structs | (Struct) { field1: "value1", field2: "value2" } |
Variants | Enum::Variant , Variant |
And the Paragraphs, leave anything after the start sign of each line intact:
As is newline |
|
Space-joined line (will trim spaces) |
|
Joined line (will trim spaces) |
The start signs can be mixed, but the first must be the vertical-bar |
.
(Save) { // 'W', // 'S',
Action::Left => 'A',
Action::Right => 'D',
},
difficulty_factor: 4.3,
respawn_point: ( // 101, //
{
"greeting": "Hello world!",
"keybinds": {
"A": "Left",
"D": "Right",
"S": "Down",
"W": "Up"
},
"difficulty_factor": 4.3,
"respawn_point": [
1107.1487,
1249.0458
],
"inventory": [
"Water",
"CannedFood",
{
"IdCard": 101
},
{
"RocketLauncher": {
"damage": 250,
"explosion_radius": 60.0
}
}
]
}
- Less syntactic noise, more intuitive look.
- Allow comments and trailing commas.
- Write KEON almost like you write Rust:
- Humanized optional type annotation.
- Distinguishable between tuples and lists (seqs).
- Arbitrary type as dictionary (map) keys.
- …
- Shorthand for newtypes.
- Support use Base64, Base32 and Base16 to represent bytes.
- Provide paragraphs may be helpful when writing something by hand.
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
struct MyData {
msg: String,
float: f32,
}
fn main() {
let dat: MyData = keon::from_str(r#"{ msg: "Hello!", float: 1123. }"#).unwrap();
println!("KEON: {}", keon::to_string(&dat).unwrap());
println!("Pretty KEON: {}", keon::to_string_pretty(&dat).unwrap());
}
Keep your files stored safely and securely with the SanDisk 2TB Extreme Portable SSD. With over 69,505 ratings and an impressive 4.6 out of 5 stars, this product has been purchased over 8K+ times in the past month. At only $129.99, this Amazon’s Choice product is a must-have for secure file storage.
Help keep private content private with the included password protection featuring 256-bit AES hardware encryption. Order now for just $129.99 on Amazon!
Support Techcratic
If you find value in Techcratic’s insights and articles, consider supporting us with Bitcoin. Your support helps me, as a solo operator, continue delivering high-quality content while managing all the technical aspects, from server maintenance to blog writing, future updates, and improvements. Support Innovation! Thank you.
Bitcoin Address:
bc1qlszw7elx2qahjwvaryh0tkgg8y68enw30gpvge
Please verify this address before sending funds.
Bitcoin QR Code
Simply scan the QR code below to support Techcratic.
Please read the Privacy and Security Disclaimer on how Techcratic handles your support.
Disclaimer: As an Amazon Associate, Techcratic may earn from qualifying purchases.