Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript Counting Array of Objects
    primarykey
    data
    text
    <p>I am been having trouble counting the number of objects in this array in server-side javascript.</p> <p>Below is a JSON object which was parsed out using the array that I am trying to count.</p> <p>NOTE: The object is in object form, not JSON string form. </p> <p>JSON Object:</p> <pre><code>[{"dataSymbol":"21135103","isHoliday":false,"isIPO":false,"lastTradeTime":40073.49652777778,"strikePrice":"33.00","last":"1.30","change":"0.20","changePct":"18.1818","lastRaw":1.3,"ask":"1.40","bid":"1.30","lastTime":40073.49652777778,"tick":0,"openInterest":"13.6K","volume":"80311","expDate":40194,"coName":"AJR Jan0 33.0 C"}, {"dataSymbol":"21339645","isHoliday":false,"isIPO":false,"lastTradeTime":40073.50479166866,"strikePrice":"6.00","last":"2.11","change":"0.01","changePct":"0.4762","lastRaw":2.11,"ask":"2.15","bid":"2.10","lastTime":40073.50479166866,"tick":0,"openInterest":"105.00","volume":"62313","expDate":40285,"coName":"EK Apr0 6.0 C"}, {"dataSymbol":"13511861","isHoliday":false,"isIPO":false,"lastTradeTime":40073.489583333336,"strikePrice":"113.00","last":"1.41","change":"-6.34","changePct":"-81.8065","lastRaw":1.41,"ask":"7.60","bid":"7.45","lastTime":40073.489583333336,"tick":0,"openInterest":"805.00","volume":"62975","expDate":40138,"coName":"SPY Nov8 113.0 P"}, {"dataSymbol":"20718334","isHoliday":false,"isIPO":false,"lastTradeTime":40073.49375,"strikePrice":"40.00","last":"1.42","change":"-0.05","changePct":"-3.4014","lastRaw":1.42,"ask":"1.46","bid":"1.44","lastTime":40073.49375,"tick":0,"openInterest":"116.1K","volume":"60470","expDate":40194,"coName":"QQQQ Jan0 40.0 P"}, {"dataSymbol":"20348966","isHoliday":false,"isIPO":false,"lastTradeTime":40073.47708333333,"strikePrice":"41.00","last":"2.39","change":"-0.06","changePct":"-2.449","lastRaw":2.39,"ask":"2.45","bid":"2.42","lastTime":40073.47708333333,"tick":-1,"openInterest":"4.6K","volume":"60320","expDate":40257,"coName":"QQQQ Mar0 41.0 P"}] </code></pre> <p>I usually use myObject.length to count this type of array, but that is not working.</p> <pre><code>Response.Write(optionsQuotes.length); </code></pre> <p>The above code is returning a result of 21339646 as the count, when the actual count of the array is 5.</p> <p>I would rather not have to loop through the array to count it, because I am looping through it later in order to draw a table, and I need to know the last iteration before the table draw begins.</p> <p>Any ideas?</p> <p>EDIT: </p> <pre><code>//here is where I am gettnig the array of objects... var myObj = common.getMyObj("param1", "param2"); </code></pre> <p>I serialized the object for the purpose of showing the contents of the array. </p> <p>myObj.constructor is an Array.</p> <p>This is on the server side also BTW.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload