Re:Select, put and delete data from JSON, TOML, YAML, XML an...
by lichtenberger on Monday March 07, 2022 @06:46PM
(#30594832)
Something like this (very simplified):
let $array := [{"foo":0,"bar":"tztz"},{"foo":"hello","bar":null},{"foo":true,"bar":"yes"}]
let $value := for $object in $array
return
let $fields := bit:fields($object)
let $len := bit:len($fields)
for $field at $pos in $fields
return if ($pos < $len) then (
$object=>$field || ","
) else (
$object=>$field || "\n"
)
return string-join($value,"")
will output: 0,tztz
hello,null
true,yes
Re:Select, put and delete data from JSON, TOML, YAML, XML an...
by kbrazil on Tuesday March 08, 2022 @01:35AM
(#30597075)
You could do something like this in pure python without the json loading boilerplate with jello[0]. An interactive TUI for jello called jellex[1} is also available. (I am the author)
Re:Select, put and delete data from JSON, TOML, YAML, XML an...
by lichtenberger on Tuesday March 08, 2022 @03:13AM
(#30597698)
JSON loading boilerplate? Is it also a compiler with sophisticated optimizations during compile time? :)
Re:Select, put and delete data from JSON, TOML, YAML, XML an...
by lichtenberger on Monday March 07, 2022 @07:52PM
(#30595260)
Of course you can simply create a module with something like the above snippet as a function for reuse. Or I can add a built-in function for flattening like this or as in pandas.
What exactly is the "transformation" you envision?