Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON object using numbers

I am running into an issue when using json that I am not sure how to approach it. I create an object like this:

var jsonObj = {"000000": 0, "010000": 1, "020000": 0 .... };

where the 0's and 1's are to act as bits. However if I were to try and call this object:

alert(jsonObj.000000);

I get an "Unexpected number" error in Chrome because it is handling the 00000 as a number and not a string. If I were to restructure the json object with a letter before the 6 numbers "c000000" then

alert(jsonObj.c000000);

Would return a correct value. Curious if anyone else has experienced anything like this and how to handle it??

like image 468
Matt Avatar asked Sep 19 '26 23:09

Matt


1 Answers

jsonObj["000000"] should work

like image 162
Thilo Avatar answered Sep 21 '26 13:09

Thilo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!