IASON
This commit is contained in:
28
DOCS.md
28
DOCS.md
@@ -509,6 +509,34 @@ The symbol `|` can be used to denote that the following fraction symbols are 1 "
|
||||
|
||||
A single "set" of fraction symbols can only represent up to 11/12, as 12/12 can be written as 1.
|
||||
|
||||
### IASON
|
||||
|
||||
> ⚠ **Warning.** The `IASON` module enables your program to read and write non-Roman numerals. Numbers handled by `IASON_LEGE` and `IASON_SCRIBE` use the decimal digits `0`–`9` (e.g. `42`, `1789`, `30`), not Roman numerals. This goes against the design philosophy of CENTVRION and should not be used unless absolutely necessary.
|
||||
|
||||

|
||||
|
||||
The `IASON` module adds two builtins for converting between `CENTVRION` values and JSON strings.
|
||||
|
||||
`IASON_LEGE(string)` parses a JSON string and returns the corresponding `CENTVRION` value. Mappings: JSON `null` → `NVLLVS`, `true`/`false` → `VERITAS`/`FALSITAS`, integer → numeral, string → string, array → array, object → `TABVLA` (string keys).
|
||||
|
||||
JSON floats with no fractional part (e.g. `3.0`) come back as integers. Other floats depend on whether the `FRACTIO` module is also loaded: with `FRACTIO`, `0.1` parses to the exact fraction `I:|::|::|S:.|S.|:` (1/10); without it, the value is floored to the nearest integer.
|
||||
|
||||

|
||||
|
||||
```
|
||||
> Marcus
|
||||
> XXX
|
||||
> [gladius scutum]
|
||||
```
|
||||
|
||||
`IASON_SCRIBE(value)` serializes a `CENTVRION` value to a JSON string. Integers and fractions become JSON numbers (fractions via shortest-round-trip float), strings become JSON strings (with the standard escapes), arrays become arrays, dicts become objects (insertion order preserved). Functions and dicts with non-string keys raise an error.
|
||||
|
||||

|
||||
|
||||
```
|
||||
> {"nomen": "Marcus", "anni": 30}
|
||||
```
|
||||
|
||||
### MAGNVM
|
||||

|
||||
|
||||
|
||||
Reference in New Issue
Block a user