- Publicity: Public Only All
json-procs.tcl
Typed JSON export of XoWiki pages. Mapping rules:
Encode using ns_json, guarded by acs::icanuse. The web method returns pretty-printed JSON and requires site-wide administrator privileges.
- Export all attributes except transient attributes prefixed with "__".
- Determine scalar types from inherited slot metadata; use explicit mappings for otherwise untyped built-in IDs and rendering flags.
- Export instance_attributes as an object, using form-field metadata to determine each stored value's type.
- Export numeric fields as numbers and boolean fields as true/false. Empty numeric and boolean values become null; empty text remains "".
- Preserve unknown types and invalid nonempty scalar values as strings. Numeric fields with keep_string_rep retain nonempty strings.
- Export multiple-value fields as arrays of strings.
- Export compound fields recursively as objects, removing the containing field's name prefix from component keys.
- Export repeated fields recursively as arrays in numeric occurrence order, omitting the occurrence-zero template. Repeated compound fields therefore become arrays of objects.
- Export stored values without applying form defaults. Preserve stored attributes no longer declared in the form; omit absent attributes.
- Location:
- packages/xowiki/tcl/json-procs.tcl
- Created:
- 2026-10-22
- Author:
- Gustaf Neumann