在 JSONPath 中,可以使用方括号和数字索引来获取数组中的元素值。

举个例子,假设有以下 JSON 数据:

{
  "books": [
    {
      "title": "Book 1",
      "author": "Author 1"
    },
    {
      "title": "Book 2",
      "author": "Author 2"
    },
    {
      "title": "Book 3",
      "author": "Author 3"
    }
  ]
}

要获取数组 books 中第一个元素的 title 值,可以使用以下 JSONPath 表达式:

$.books[0].title

在这个例子中,$.books[0] 表示获取 books 数组的第一个元素,然后使用 .title 来获取该元素的 title 值。

JSONPath 获取数组索引值:详细教程

原文地址: https://www.cveoy.top/t/topic/o4gy 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录