l0.dkjson¶
DependencyControl wrapper around David Kolf's dkjson: a thin overlay on the vendored upstream module,
adding a DependencyControl version record and a Prettier-flavored indentMode encode option while
deferring every other call to upstream dkjson.
The bare specifiers this module provides are "json" and "dkjson", resolved by DependencyControl's
module searcher. A locally installed dkjson, luajson, or other JSON module imported by bare specifier
takes precedence over this one.
Functions¶
encode ¶
Encodes a Lua value as JSON. With state.indentMode set to "prettier", output is Prettier-flavored:
two-space indents, one property per line, arrays inlined when they fit state.indentPrintWidth, and a
trailing newline. Any other indent mode (or none) defers entirely to upstream dkjson.
A reference cycle raises "reference cycle", as upstream dkjson does in every other encode mode.
| param | type | description |
|---|---|---|
| value | any |
The value to encode. |
| state? | DkJsonEncodeState | Encode state carrying the Prettier options plus any upstream dkjson state. |
Returns:
jsonstring|boolean— The JSON string, ortruewhenstate.bufferis supplied (upstream dkjson's native return).
Types¶
DkJsonEncodeState ¶
dkjson encode state, extended with the DependencyControl wrapper's Prettier options.
| field | type | description |
|---|---|---|
| indentMode? | string |
Set to "prettier" for Prettier-flavored formatting; any other value defers to upstream dkjson. |
| indentPrintWidth? | integer |
Target line width for the prettier indent mode. Defaults to 80. |
| defaultKeyOrder? | fun(a: any, b: any): boolean |
Sorts object keys absent from keyorder, returning true when the first sorts ahead. Defaults to case-insensitive alphabetical, and applies only in the prettier indent mode. |
| keyorder? | any[] |
Object keys emitted first, in this order, ahead of defaultKeyOrder. |
DkJson ¶
David Kolf's dkjson, wrapped for DependencyControl.
| field | type | description |
|---|---|---|
| version | DependencyControl | The DependencyControl record, populated on initialization. |