xowiki::json_scalar (private)
xowiki::json_scalar type value
Defined in packages/xowiki/tcl/json-procs.tcl
Return an ns_json type/payload pair. Empty typed scalars become null; invalid nonempty legacy values remain strings.
- Parameters:
- type (required)
- Requested JSON scalar type: number, boolean, or string.
- value (required)
- Stored scalar value, without applying form defaults.
- Returns:
- Two-element list containing the ns_json type and payload.
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- No testcase defined.
Source code: if {$value eq "" && $type in {number boolean}} { return [list null ""] } switch -- $type { boolean { switch -nocase -- $value { t - true - yes - on - 1 {return {boolean true}} f - false - no - off - 0 {return {boolean false}} } } number { # JSON numbers exclude NaN, infinity, hexadecimal and leading zeros. if {[regexp {^-?(0|[1-9][0-9]*)(\.[0-9]+)?([eE][+-]?[0-9]+)?$} $value]} { return [list number $value] } } } return [list string $value]XQL Not present: Generic, PostgreSQL, Oracle