可以使用JSON对象中的键查询数据的JSON查看器

时间:2015-09-12 22:03:45

标签: json

我想知道是否有一个可以从json对象数组中获取特定数据的在线工具

例如,我有这个JSON数组

{ "results": [
    {
        "createdAt": "2015-09-02T02:03:55.765Z",
        "name": "Clush",
        "score": 15,
        "updatedAt": "2015-09-12T21:03:57.773Z",
        "userId": "5645645"
    },
    {
        "createdAt": "2015-09-06T00:17:52.225Z",
        "name": "hello",
        "score": 9,
        "updatedAt": "2015-09-06T07:41:27.749Z",
        "userId": ""
    },
    {
        "createdAt": "2015-09-08T01:21:09.970Z",
        "name": "test",
        "score": 50,
        "updatedAt": "2015-09-08T01:21:14.787Z"
    },
    {
        "createdAt": "2015-09-08T01:21:20.037Z",
        "name": "test2",
        "score": 88,
        "updatedAt": "2015-09-08T01:21:23.140Z"
    },
    {
        "createdAt": "2015-08-27T02:13:35.869Z",
        "name": "Hana",
        "score": 8,
        "updatedAt": "2015-09-11T20:39:36.037Z",
        "userId": "7678889"
    }
] }

我只想获取名称字段下的值 并将其保存在单独的文件中。

所以在我的另一个文件中我应该只有

Clush
hello
test
test2
Hana

我看过一些JSON查看器,但似乎他们没有这个 功能。

2 个答案:

答案 0 :(得分:1)

您可以使用此服务:http://ashphy.com/JSONPathOnlineEvaluator/

在输入文本框中输入 $。results [*]。name

在评估结果窗格中,您将获得

'0' => "Clush"
'1' => "hello"
'2' => "test"
'3' => "test2"
'4' => "Hana"

答案 1 :(得分:1)

另一项服务是https://jsonpath.curiousconcept.com/

它使用JsonPath( https://www.google.com/search?q=jsonpath&ie=utf-8&oe=utf-8

因此查询$..name将获得一个只包含名称值的数组(您需要从右侧的下拉列表中选择 stefan goessner 实现