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
json array length in javascript is returing the string length - Stack Overflow
tried to use the historydata.length and its showing 57 (its considering json array as a single string and showing its length ) I want the array size More on stackoverflow.com
🌐 stackoverflow.com
December 13, 2015
🌐
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
🌐
Tabnine
tabnine.com › home › code library
Code Library - Tabnine
July 25, 2024 - Get the answers and suggestions you need from our AI code assistant. Get started in minutes with a free 90 day trial of Tabnine Pro.
🌐
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