Grab information from a JSON file with spaces

Asked

Viewed 125 times

1

I am developing an application using Javascript and I need to get some information from a JSON file, but this file comes with spaces. I wonder if it is possible to get this information even with the spaces?

{
     "Meta Data": {
            "1. Information": "Intraday Prices and Volumes for Digital Currency",
            "2. Digital Currency Code": "BTC",
            "3. Digital Currency Name": "Bitcoin",
            "4. Market Code": "EUR",
            "5. Market Name": "Euro",
            "6. Interval": "5min",
            "7. Last Refreshed": "2018-07-27 00:25:00",
            "8. Time Zone": "UTC"
}, ...
  • The spaces are the identacões? If yes, the answer is yes, when to do JSON.parse the result will be the same regardless of how many spaces

  • Are you having a problem? It’s normal to pick up the blanks.

  • I believe that the spaces are not the identations, using the parse function, I would like to take the information of "Meta Data", but I can not get this information with spaces

  • I imagine it is as if it were the case: {"name user": "user1"}

1 answer

2


I had the same problem, I had to consume an API that had properties with spaces and hyphens, use:

obj["prop 1"];
obj["prop-2"];
obj["prop. 3"];
//...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.