inherit
162752
0
Nov 7, 2024 3:58:23 GMT -8
Pebble
Where it all does or doesn't happen!
1,437
January 2011
pebbleleague
|
Post by Pebble on Jan 20, 2016 13:16:12 GMT -8
Hi Everyone, I'm maybe missing the obvious but is there a way to find the current length of a key? I'm currently unshifting to a key and poping if the number of arrays is over 54 as I've got a max length for each entry. I'd rather do this if I know the key length is , say, 3.8k or more. Is there an easy way rather than looping through each array? ( It's been sooo long since I've coded I think I've got my array/objects in a twist but the below example will make it more obvious what I mean. ) An example of the thread key: ["Leaderboard", 63, [{"e":"938","c":"Windows","a":"klizy","b":"117352","d":"Tesla Model"},{"e":"938","c":"Windows","a":"klizy","b":"117385","d":"Tesla Model"},{"e":"938","c":"Windows","a":"klizy","b":"117649","d":"Tesla Model"},{"e":"938","c":"Windows","a":"Grey Goose","b":"116956","d":"Tesla Model"},{"e":"938","c":"IOS","a":"Anton","b":"117616","d":"Tesla Model"},{"e":"938","c":"Windows","a":"Pebble","b":"117682","d":"Tesla Model"},{"e":"938","c":"Windows","a":"klizy","b":"117682","d":"Tesla Model S"},{"e":"938","a":"orez","b":"119134","d":"Tesla Model S"},{"e":"926","a":"ThirtyBird","b":"118903","d":"Tesla Model S"},{"e":"938","a":"Pebble","b":"118012","d":"Tesla Model S"},{"e":"938","a":"Kiwi Claire","b":"117748","d":"Tesla Model S"},{"e":"938","a":"klizy","b":"117682","d":"Tesla Model S"},{"e":"938","a":"CEJ","b":"117616","d":"Tesla Model S"}]] Thanks in advance, as always.
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Jan 20, 2016 13:45:31 GMT -8
Pebble, Best way is to just turn it into a string... JSON.stringify(obj).length
|
|