When you tries to access
You are actually trying to refer element at very first memory location in an array, but
var string is a hash not array.
Thats why you are getting
I have no idea what you want
obj to do, so I can't help with that.
To get the value for key31, use
obj.Key3.key31, which, when logged, should yield
your variable (String) is not array its object in above case and you can not access using indexing like 0,1,2... ,you can access this with its key value name like key1,key2...
example: obj['key1'] $ value obj['Key3']['key31'] $ value 31