如何从邮递员的JSON对象数组中获取JSON对象? [英] How to get JSON object from array of JSON objects in postman?

查看:113
本文介绍了如何从邮递员的JSON对象数组中获取JSON对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在其他线程上寻找了一段时间,并且问题没有得到如何获取数组
中的JSON对象我已经看过的问题-
如何从邮递员中的JSONArray中获取JSONobject

如何从JSON对象获取数组?

Looked for while on other threads and questions didn't get how to get JSON object in array questions I have already looked at - How to get JSONobject from JSONArray in postman
How to get array from JSON Object?

到目前为止,我已经尝试过-

what I have tried so far -

var jsonData = JSON.parse(responseBody);
var jsonObject = jsonData.events[2];
console.log("jsonobject - " + jsonObject);

控制台输出-

jsonobject - [object Object]

json响应如下-

[
 {

        "$ts": "2019-06-14T06:21:55.2221392Z",
        "values": [
            "43912",
            "CountIn",
            "neet.row.mac3.indexinput",
            "mac3",
            "mac3",
            "mac3",
            300,
            11,
            1,
            "mac3",
            "2019-06-14T06:21:55.2221392Z",
            "2019-06-14T06:22:55.2221392Z",
            "manager",
            "lead",
            "consultant",
            "5ca1e66d7eb20a11f00e502c
        ]
    },
    {

        "$ts": "2019-06-14T06:23:54.3263475Z",
        "values": [
            "44272",
            "indexinput",
            "neet.row.mac2.indexinput",
            "mac2",
            "mac2",
            "mac2",
            300,
            11,
            1,
            "mac2",
            "2019-06-14",
            "2019-06-14",
            "Head",
            "Master",
            "Student",
            "5ca1e66d7eb20a11f00e502c"
        ]
    },
    {
        "$ts": "2019-06-14T06:24:54.3753534Z",
        "values": [
            "44452",
            "indexinput",
            "neet.row.mac.indexinput",
            "mac",
            "mac",
            "mac",
            300,
            11,
            1,
            "Neet",
            "2019-06-14T06:24:54.3753534Z",
            "something1",
            "something2 of something1",
            "something3 of something2 ",
            "5ca1e66d7eb20a11f00e502c"

        ]
    }
]


推荐答案

看起来您正在获取对象,但控制台将其打印为[object Object]。尝试打印 jsonObject。$ ts jsonObject.values [0] 来查看对象是否包含您要查找的数据

Looks like you are getting the object, but the console is printing it as [object Object]. Try printing jsonObject.$ts or jsonObject.values[0] to see if the object contains the data you are looking for.

这篇关于如何从邮递员的JSON对象数组中获取JSON对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆