I'm trying to print the length of this JSON Object to the console but I keep receiving 'undefined'.
This is being JSON encoded in PHP and then returned via ajax to an anonymous function as 'msg'
{"1":{"item_id":"shirt_straight--small","quantity":5},"2":{"item_id":"shirt_straight--medium","quantity":"2"}}
Printing to console:
console.log(msg.length); //undefined
console.log(msg[1].item_id); //shirt_straight--small
I'm able to print the value of msg[1].item_id but I'm not able to get the length via msg.length
Thanks for your help.