Tutorial :How do you write in JavaScript a empty key from JSON?



Question:

Let's say you have the following JSON object

{"":"some text"}  

How do you retrieve it in JavaScript?

json_in_var={"":"some text"}    alert(json_in_var.)  

I'm perplexed on this one, any help welcome!


Solution:1

It's an syntax error to refer to it with

json_in_var.  

However, you can access it like this:

json_in_var[""]  


Solution:2

Easily...

alert(json_in_var[""]);  


Solution:3

I was able to solve this by using

alert(json_in_var.$t)  

This is when retrieving Blogger feeds in json format. I am unsure if this is proprietary.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »