Crates.io | fson |
lib.rs | fson |
version | 0.1.0 |
source | src |
created_at | 2023-11-26 15:52:28.296568 |
updated_at | 2023-11-26 15:52:28.296568 |
description | Flexible Serialized Object Notation |
homepage | |
repository | https://github.com/zalupa35/fson |
max_upload_size | |
id | 1049220 |
size | 42,644 |
FSON (Flexible Serialized Object Notation) is an extension for JSON that is used primarily for configuration. The user can quickly configure the configuration using references or a template strings.
/* Multiline comment */ [null, NaN, Infinity, -Infinity, 0x1ABC /*Hexadecimal*/] // Single comment
{
"double quotes": null,
'single quotes': null,
withoutQuotes: null
}
{
something: {
key: #{ #id: "identifier"; #value: "value"; }
}
}
#identifier
or #"identifier"
#/something/identifier
or #/"something"/"identifier"
${value}
. For example:
{
x: 5,
something: `x is ${x}`
}
{ x: { y: [], }, }
+1.5
"hello
world"
See all examples in Examples directory.
How to run example:
cargo run --example EXAMPLE_NAME
FSON is already ready for compilation to WebAssembly and already has the
necessary functions. js-sys
and wasm-bindgen
libraries and functions are
used only when compiling to WebAssembly.
Use these commands to compile
to wasm:
# Install wasm-pack
cargo install wasm-pack
# Compile to wasm
wasm-pack build --target web
import init, { parse, stringify } from "./jsonparser.js";
init().then(() => {
console.log(stringify({
// Creating reference
x: {
"#id": "test",
"#value": "value",
},
// Using reference
y: [
// Identifier
{ "#reference_id": "test" },
// Path
{ "#reference_path": ["x"] },
// Template string
{
"@template_string": [
"test is ",
{ "#reference_id": "test" }, /* Reference */
"; 2 + 2 = ",
4, /* Normal value */
],
},
],
}));
});
MIT