Struggling to output the length of this JSON Object on the console, but all I get is 'undefined'.
This JSON data is encoded in PHP and then sent back via ajax to an unnamed function as 'msg'
{"1":{"item_id":"shirt_straight--small","quantity":5},"2":{"item_id":"shirt_straight--medium","quantity":"2"}}
When trying to print to the console:
console.log(msg.length); //undefined
console.log(msg[1].item_id); //shirt_straight--small
I can access the value of msg[1].item_id but getting the object's length through msg.length remains elusive.
Your assistance is much appreciated!