views:

197

answers:

3

Hello todos!

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!

+8  A: 

It's an syntax error to refer to it with

json_in_var.

However, you can access it like this:

json_in_var[""]
Guðmundur H
+2  A: 

Easily...

alert(json_in_var[""]);
Josh Stodola
A: 

Thanks for the quick replies. I've actually been able to solve this by using

alert(json_in_var.$t)

This is when retrieving Blogger feeds in json format. Could that be somehow proprietary? I´m gon try with my own scripts. Anyhoo, thanks for the help guys!

There's nothing special about $t, it's a legal JavaScript name — if you were thinking about that.
Guðmundur H