xowiki::formfield::CompoundField instproc json_value (public)

 <instance of xowiki::formfield::CompoundField[i]> json_value value

Defined in /var/www/openacs/packages/xowiki/tcl/json-procs.tcl

Recursively export stored components as a JSON object. Strip the containing field's name prefix from component keys, omit transient components, and retain unknown components as strings. Invalid legacy values that are not dictionaries remain strings.

Parameters:
value (required)
Stored dictionary of fully qualified component names and values.
Returns:
Two-element ns_json type/payload pair; object payloads contain triples.

Testcases:
No testcase defined.
Source code:
if {[catch {dict size $value}]} {
  return [list string $value]
}
set entries {}
dict for {name v} $value {
  set key $name
  set prefix ${:name}.
  if {[string first $prefix $name] == 0} {
    set key [string range $name [string length $prefix] end]
  }
  if {[string match __* $key]} {
    continue
  }
  set type string
  set payload $v
  foreach c ${:components} {
    if {[$c name] eq $name} {
      lassign [$c json_value $v] type payload
      break
    }
  }
  lappend entries $key $type $payload
}
return [list object $entries]
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: