Before going to answer read this Documentation once. Then you clearly understand the answer.

Try this It may work for you.

Object.keys(data.shareInfo[i]).length
Answer from James on Stack Overflow
🌐
Reddit
reddit.com › r/learnjavascript › grabbing the length of an array in json object
r/learnjavascript on Reddit: Grabbing the length of an array in json object
March 22, 2021 -

My question is pretty straight forward,

I am trying to grab the lenght of an array returned by my json. However, the array could be possibly two different names (for example orange or apple)

so how would I write code that would just grab the array length regardless of the array name

Discussions

JSON array get length using jQuery or javascript - Stack Overflow
I know there are many similar questions to this. But any of them doesn't work for me. I have a json array which the whole structure is like this: The array the i want to get is this: The structure... More on stackoverflow.com
🌐 stackoverflow.com
Size of JSON array
Hi. I have calls that return me an xml. To navigate the response, I first convert it to JSON with the following: var jsonObject = xml2Json(responseBody); I then address its parts with variables hierarchically like this: var x = jsonObject[‘x’] var y = x[‘y’] My goal is to use the test ... More on community.postman.com
🌐 community.postman.com
8
0
August 9, 2019
javascript - get size of JSON object - Stack Overflow
Your problem is that your phones object doesn't have a length property (unless you define it somewhere in the JSON that you return) as objects aren't the same as arrays, even when used as associative arrays. If the phones object was an array it would have a length. More on stackoverflow.com
🌐 stackoverflow.com
September 3, 2017
jquery - Cannot get the length of JSON array in javascript - Stack Overflow
I have read other issues regarding ... array in javascript, but nothing helped in my case. I am receiving the below json in jquery ajax call. {"jList":"[{\"added_by\":\"Ani\",\"description\":\"example description.\",\"start_date \":\"2014-10-10\",\"mark\":255,\"id\":975},{\"added_by\":\"Ani\",\"description \":\"example description..\",\"start_date\":\"2014-10-10\",\"mark\":255,\"id\":980 }]"} ... All I want is to count the JSON objects in this array. In the above case I want an length output as ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
EyeHunts
tutorial.eyehunts.com › home › javascript json array length | example code
JavaScript JSON Array length | Simple Example code
December 6, 2021 - Use Object.keys(myObject).length method to get JSON array length in JavaScript. In method you have to use data name and filed name to get...
🌐
Micro Focus
microfocus.com › documentation › silk-performer › 195 › en › silkperformer-195-webhelp-en › GUID-C7D13D2C-FC89-4656-83CD-107C4345B82D.html
Getting and Setting the Size of a JSON Array - Micro Focus
transaction TMain var jsonArray : number; arrayLength : number; begin jsonArray := JsonParse("[0,1,2,3,4]"); arrayLength := JsonGetArrayLength(jsonArray); Print("Length: " + string(arrayLength)); JsonFree(jsonArray); end TMain; Output Length: 5
🌐
TutorialsPoint
tutorialspoint.com › article › best-way-to-find-length-of-json-object-in-javascript
Best way to find length of JSON object in JavaScript
September 22, 2022 - Object.keys().length is the most efficient and recommended approach for finding the length of a JSON object in modern JavaScript.
🌐
Postman
community.postman.com › help hub
Size of JSON array - Help Hub - Postman Community
August 9, 2019 - Hi. I have calls that return me an xml. To navigate the response, I first convert it to JSON with the following: var jsonObject = xml2Json(responseBody); I then address its parts with variables hierarchically like this: var x = jsonObject[‘x’] var y = x[‘y’] My goal is to use the test script to figure out how many elements the x-array has, i.e. how many y-blobs there are (how many y children of the main x object).
Find elsewhere
🌐
YouTube
youtube.com › watch
How to Correctly Obtain the Length of a JSON Array in JavaScript - YouTube
Learn how to accurately determine the length of a JSON array in JavaScript using straightforward and effective methods.---Disclaimer/Disclosure: Some of the ...
Published: January 27, 2025
Views: 7
🌐
Micro Focus
microfocus.com › documentation › silk-performer › 205 › en › silkperformer-205-webhelp-en › GUID-C7D13D2C-FC89-4656-83CD-107C4345B82D.html
Getting and Setting the Size of a JSON Array
transaction TMain var jsonArray : number; arrayLength : number; begin jsonArray := JsonParse("[0,1,2,3,4]"); arrayLength := JsonGetArrayLength(jsonArray); Print("Length: " + string(arrayLength)); JsonFree(jsonArray); end TMain; Output Length: 5
🌐
CodingTechRoom
codingtechroom.com › question › get-length-json-array-javascript
How to Get the Length of a JSON Array in JavaScript? - CodingTechRoom
This property returns the number of elements in the array, making it straightforward to get the required information rapidly. For practical refactoring techniques, Refactoring, Second Edition is a useful companion. ... let jsonString = '["apple", "banana", "cherry"]'; let jsonArray = JSON.parse(jsonString); let length = jsonArray.length; console.log(length); // Outputs: 3
🌐
Processing
processing.org › reference › JSONArray_size_
size() / Reference / Processing.org
// // [ // { // "id": 0, // "species": "Capra hircus", // "name": "Goat" // }, // { // "id": 1, // "species": "Panthera pardus", // "name": "Leopard" // }, // { // "id": 2, // "species": "Equus zebra", // "name": "Zebra" // } // ] JSONArray values; void setup() { values = loadJSONArray("data.json"); println("JSONArray size is " + values.size()); } // Sketch prints: // JSONArray size is 3
🌐
Tibco
integration.cloud.tibco.com › docs › Subsystems › flogo › mapper-functions-guide › json_length.html
json.length
This function gets the number of top-level elements in the JSON object or array. json.length(jsonObjectOrArray) Let us say the jsonObject includes the following. jsonObject = { "id": 1, "name": "bob" } The function json.length(jsonObject) returns 2. Copyright © .