如何计算键值类型对象的值 [英] How to fecth the values of key value type object

查看:98
本文介绍了如何计算键值类型对象的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含7个对象的数组。每个对象都有一个键和值(这个值包含对象)。如何获取值对象。



0:对象//这是7中的第一个对象。

键:41170760 //这是它的关键。

值:对象//这是它的值,它又是一个对象。我想取下面的值。

ASICeligibleInd:null

BCentreId:41170760

BCentreName:ALPHA NATIONAL

CId:41170760

CName:Alphalobal



我的尝试:



var dataInputValues = Object.values(dataInput);

I have a array of 7 objects. Each object have a key and value(this values is containing object). how to get the values object.

0: Object//This is the first object out of 7.
Key: 41170760//this is its key.
Value: Object//this is its value which is again a object. I want to fetch its below values.
ASICeligibleInd: null
BCentreId: 41170760
BCentreName: "ALPHA NATIONAL "
CId: 41170760
CName: "Alphalobal"

What I have tried:

var dataInputValues=Object.values(dataInput);

推荐答案

使用数组索引获取值,照顾案例,因为 Javascript 区分大小写。



use array index to get the values, Take care of the case , since Javascript is case sensitive.

for (var i = 0; i < arrayObject.length; i++) {
           var key = arrayObject[i].Key;
           var valueObject = arrayObject[i].Value;
       }





要获取特定的索引值,请说第4项(因为基于零的索引)



To Get a particular index value, say 4th Item ( since zero based index )

var key = arrayObject[3].key;
       var valueObject = arrayObject[3].Value;


这篇关于如何计算键值类型对象的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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