我有一条选择语句
select(index("FooItems")) | .[3].texts )
从此JSON返回所有texts
数组的数组:
[...],
[
"create",
"w100",
"FooItem",
{
"parent":"w90",
"texts":["","","baritem71","baritem22","",""]
}
],
[
"create",
"w122",
"FooItem",
{
"parent":"w93",
"texts":["","","baritem38","baritem17","",""]
}
],
[...]
结果数组如下:
[...],[ "", "", "baritem71", "baritem22", "", "" ], [ "", "", "baritem38", "baritem17", "", "" ],[...]
如何继续进行操作并使其丢弃空字符串元素,以使输出看起来像这样:
[...],["baritem71", "baritem22"], [ "baritem38", "baritem17"],[...]
我尝试仅使用texts
中非零字符串的索引,因为它们始终位于位置2和3:
.texts[2,3]
但这只是返回一个数组中的所有非零值:
["baritem71", "baritem22", "baritem38", "baritem17"]
谢谢!