Repository navigation
stury 0.2.0
·
31 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
Library
- New format packages
toml(TOML 1.0 and 1.1),yaml(YAML 1.2, core schema),xml(XML 1.0 with namespaces and the
internal subset),html(the WHATWG tokenizer, tree builder and serializer) andcbor(RFC 8949, with
preferred, deterministic and length-first specs). Each has the samevalidate,build,find,scan,query,
unmarshal,marshaland edit calls asjsonanddsv, and edits keep every byte they do not target. - Facts carry across formats: comments, YAML tags, anchors and styles, TOML datetimes and number forms, XML and HTML
attributes and namespaces, CBOR tags and byte strings. A conversion writes a fact where the output holds it, and a
comment keeps one place in every format. core/modelloads and dumps Odin structs under a registry of rules (tags, defaults, validators, hooks, unions,
patch), judged with the same error kinds as a JSON Schema.core/schemacompiles and binds JSON Schema drafts 4, 6,
7, 2019-09 and 2020-12, and infers, samples, compares and converts through a schema and writes a description as
Odin types (schema.write_odin).core/difftells the changes between two values, with keys, sets and facts.core/cssmatches CSS selectors
over XML and HTML.core/regexis an Oniguruma and ECMA regex engine with Unicode 17 tables.- Every call that fails returns
core.Error, one union thatcore.renderwrites. A refusal names the type wanted and the
value found, and a writer's refusal names its reason in the format's words. - A format package takes its spec in
format, asjson.format(src, .Json5), and forwardscomment,end_record,
reorderandset_facts. The edit list's setter iswrite.set_nodein every format. core/recordsreads and writes records of every format, into documents or typed values, including CSV and TSV
throughrecords.WriterwithWrite_Options.grow_header, and reads the records under a path of keys with.Entries.- A repeated key follows one
dupsfield of the read's options in every format. - A hex, octal or binary integer, or one with underscores, compares equal to its decimal.
- JSON's walk passes its state in registers between states, a compact write drops blanks with
vpcompressbon an
Intel CPU with AVX512-VBMI2, and a map of 1024 keys or more is written sorted by a radix sort. unmarshalof TOML, and of YAML whose members read from their tokens alone, builds no document. A TOML path read
understop_earlyparses only the statements its answer needs.- A TOML or XML build walks its text once. A TOML table tree keeps its comments apart, and an HTML tree grows in chunks
that are never copied, so both builds hold less memory. - A typed TOML write lays out its tables in one pass and writes a bare key bare, and a typed XML write writes its
elements with no value built in between. - A document read from CBOR, YAML, XML or TOML is written without examining again what its read already judged: a CBOR
string or small integer, a YAML plain or single-quoted scalar and a TOML basic string are copied as they were read.
A TOML basic string keeps its escapes, as a JSON string does, unlessrespell_stringsorasciiis set. - An HTML write and an HTML edit check what they wrote by comparing the tree it reads back, with no second write.
- A query over a built document stops reading an array once the element or the first key its step picks has passed.
records.validatereads a YAML stream or a CBOR sequence in pieces on threads, and a CBOR sequence's items are
judged by the walk that frames them.- A JSON Schema whose
anyOf,oneOf,notorifarms read only member names and those members' own values is
judged with no branch run for them, andunevaluatedPropertiesbeside such arms is settled when the schema compiles. - A buffer output starts at 1 KiB, and a compact write reserves no room for line breaks, so many small writes into one
arena hold less memory.
Command line
- Reads and writes TOML, YAML, XML, HTML, CBOR and JSON5 as well as JSON, JSONC, NDJSON, CSV and TSV.
--fromand--to
take a spec after a colon (toml:1.0,html:fragment,cbor:deterministic). Without--from, the extension of the
named files picks the format. fmtconverts between formats and keeps comments, number spellings, tags, directives and layout where the output has
them. It refuses with exit 5 a value its output cannot hold and says why.editapplies a jq filter to a text and keeps every byte the filter does not change, in every format.--difftells
the changes, per document for a YAML stream..@comment,.@comment_inline,.@comment_foot,.@style,.@tag,.@directivesand.&NAMEread and write
facts and attributes, and.@(name)and.&[name]take a computed name. A step that names an unknown fact is an
error.css(selector)selects the elements of an XML or HTML input.--attributesreads each attribute of an XML or HTML element as its member@NAME, and writes such a member back
as an attribute.check --schema FILEjudges each input against a JSON Schema and tells every failure.check --filter F --schema S
types a filter against the schema of its inputs.--schema-draftnames the draft of a schema with no$schema.difftells what differs between two inputs, two schemas (--compat) or a schema and data.schema infer,schema sampleandschema genwrite a JSON Schema from inputs, values that pass a schema, and the
Odin types a model reads its values with.--streamreads every format, and--seqreads JSONC and JSON5 records.--to json5is accepted, andfmt
reads and writes JSON5 with--checkand--in-place.- A YAML integer past 64 bits, a TOML number with underscores and a JSON5 number with a sign or a lone point read and
convert by their value and keep their spelling where the output has it.