You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用JOLT按JSON键值对排序?适配问答数量可变场景

基于JOLT实现动态问答数据按序列升序排序

需求:对JSON对象的键值对数据按questionSequence字段升序排序,同时适配问答数量不固定(可动态增减)的场景。

输入示例

{
  ".0.answer": "In tag functionality ",
  ".0.question": "Provide a brief description",
  ".0.questionSequence": 1,
  ".1.answer": "In Git if we want to know",
  ".1.question": "Use Case Description ",
  ".1.questionSequence": 3,
  ".2.answer": "In Git if we want to know PIT",
  ".2.question": "Business Justification ",
  ".2.questionSequence": 2
}

期望输出示例

{
  ".0.answer": "In tag functionality ",
  ".0.question": "Provide a brief description",
  ".0.questionSequence": 1,
  ".2.answer": "In Git if we want to know PIT",
  ".2.question": "Business Justification ",
  ".2.questionSequence": 2,
  ".1.answer": "In Git if we want to know",
  ".1.question": "Use Case Description ",
  ".1.questionSequence": 3
}

JOLT配置方案

[
  {
    "operation": "shift",
    "spec": {
      "*": "*questionSequence"
    }
  },
  {
    "operation": "sort"
  }
]

内容的提问来源于stack exchange,提问作者self lab

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.02 09:12:10