How do you write a blank JSON key in JavaScript?

Say you have the following JSON object

{"":"some text"}

How can you get it in javascript?

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

I am puzzled by this, any help is appreciated!

+3
source share
3 answers

This is a syntax error for referencing it using

json_in_var.

However, you can access it as follows:

json_in_var[""]
+14
source

Easily...

alert(json_in_var[""]);
+2
source

I was able to solve this using

alert(json_in_var.$t)

This is when extracting Blogger feeds in json format. I am not sure if it is proprietary.

-3
source

Source: https://habr.com/ru/post/1704612/


All Articles