Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
用xidel列出所有json指针_Json_Xidel - Fatal编程技术网

用xidel列出所有json指针

用xidel列出所有json指针,json,xidel,Json,Xidel,是否可以使用或其他命令行工具从文件中列出/生成所有 我试过了 xidel test.json -e '$json()' 但是它只列出顶级字段,而我想要一个递归列表,就像我用xmlstarlet el-a得到的那样。您可以为此声明一个递归函数: xidel test.json -e ' declare function escape ($s) { replace(replace($s, "~", "~0"), "/", "~1") }; declare function

是否可以使用或其他命令行工具从文件中列出/生成所有

我试过了

xidel test.json -e '$json()'

但是它只列出顶级字段,而我想要一个递归列表,就像我用
xmlstarlet el-a

得到的那样。您可以为此声明一个递归函数:

xidel test.json -e '
      declare function escape ($s) { replace(replace($s, "~", "~0"), "/", "~1") };
      declare function enum($v, $pointer) {
        typeswitch ($v) 
          case array()  return $v() ! enum(., $pointer || "/" || string(position() - 1))
          case object() return $v() ! enum($v(.), $pointer || "/" || escape(.))
          default       return $pointer
      };
      enum($json, "")
'

哇,总是很惊讶Xidel是如此强大和多才多艺。你写的机器人仍然比我高很多。我还在你的xidel github上发现了reddit聊天机器人,但它的大部分内容对我来说都是陌生的领域。我希望有一个更简单的解决方案,但它能工作。它还会抛出错误。