Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在jquery中获取JSON对象长度?_Jquery_Json - Fatal编程技术网

如何在jquery中获取JSON对象长度?

如何在jquery中获取JSON对象长度?,jquery,json,Jquery,Json,我在JSON数组中有两个JSON对象,如下所示 array.put(resObj); array.put(resObjPrd); 我返回这个数组作为Jquery ajax响应。有人能解释一下如何使用Jquery获得第二个对象的长度吗? 这是我的Jquery ajax代码 $.ajax({ type: 'POST', url: "fetch", dataType: 'json', data: { clientidedit: clientidedi

我在JSON数组中有两个JSON对象,如下所示

array.put(resObj);

array.put(resObjPrd);
我返回这个数组作为Jquery ajax响应。有人能解释一下如何使用Jquery获得第二个对象的长度吗? 这是我的Jquery ajax代码

$.ajax({
    type: 'POST',
    url: "fetch",
    dataType: 'json',
    data: {
        clientidedit: clientidedit
    },
    success: function(data) {
        alert(data[1]);

    }
});

可以使用
JSON.stringify()
检索
对象的字符串表示形式
,然后返回stringized对象的
.length
var obj={“abc”:123};
var objStr=JSON.stringify(obj);

console.log(objStr.length)
“如何获取第二个对象的长度”是
resObjPrd
an
数组
<代码>数据[1]。长度?我在发出警报时未定义(数据[1]。长度);“在警报(数据[1].length)时获取未定义”是
resObjPrd
一个
Array
?resObjPrd和resObj是两个JSON对象..我将它添加到JSON数组“Array”中。我想获取第二个对象的长度
对象
{}
没有
.length
属性。虽然可以使用
JSON.stringify()
获取
对象的字符串表示形式
,然后返回stringized对象的
长度