Getting over-complex with the JSON there folk!!
Object.keys(myObj).length
should do the job, no need for anything complex.