News for hackers. Stuff that matters.
Re:Select, put and delete data from JSON, TOML, YAML, XML an... by lichtenberger on Monday March 07, 2022 @06:33PM (#30594746)
Of course you can do it with http://brackit.io.

What exactly is the "transformation" you envision?

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)

[0] https://github.com/kellyjonbrazil/jello

[1] https://github.com/kellyjonbrazil/jellex

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.