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

如何使用JSONPath提取金额大于10的客户custId与custName

提取符合条件的客户字段的JSONPath表达式

核心表达式(返回仅含指定字段的对象数组)

$.customers[?(@.itemAmount > 10)]['custId', 'custName']

表达式拆解

  • $.customers:定位到根节点下的customers数组
  • [?(@.itemAmount > 10)]:过滤数组中itemAmount大于10的元素,@指代当前遍历的数组元素
  • ['custId', 'custName']:仅保留每个符合条件元素中的custId和custName字段

可选需求的表达式

如果需要单独提取某一字段的列表:

  • 提取所有符合条件的custId:
    $.customers[?(@.itemAmount > 10)].custId
    
  • 提取所有符合条件的custName:
    $.customers[?(@.itemAmount > 10)].custName
    

验证用的完整JSON数据(修正原数据语法错误)

{
  "customers": [
    {
      "custId": 540,
      "custName": "John",
      "itemId": 647,
      "itemAmount": 3000
    },
    {
      "custId": 432,
      "custName": "Adrian",
      "itemId": 600,
      "itemAmount": 2000
    },
    {
      "custId": 541,
      "custName": "Smith",
      "itemId": 320,
      "itemAmount": 1200
    }
  ]
}

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.06 17:35:40