Fetching values that have spaces
lucasomigli opened this issue · 3 comments
Working with an API that has object values with spaces. Tried getting the values with {{Line with spaces}}
and {{"Line with spaces"}}
as a second parameter for returning an object value but gives a return of notFound
. Any ideas?
Thanks for reaching out! I am not able to reproduce the issue. I tested and verified that it works with spaces like {{Line with spaces}}
. Can you provide some sample JSON from the API (or something syntactically similar) and the template
you are using (i.e. {{Line with spaces}}
). You may have an edge case with spaces that I have not considered.
Sure. So the API I am working with returns a JSON object which contains spaces in all of its values:
{ "Realtime Currency Exchange Rate": { "1. From_Currency Code": "USD", "2. From_Currency Name": "United States Dollar", "3. To_Currency Code": "JPY", "4. To_Currency Name": "Japanese Yen", "5. Exchange Rate": "109.94000000", "6. Last Refreshed": "2019-05-11 15:52:23", "7. Time Zone": "UTC", "8. Bid Price": "109.89000000", "9. Ask Price": "109.99000000" } }
At the moment I am fetching data with =GETJSON("https://www.alphavantage.co/query?function=CURRENCY_EXCHANGE_RATE&from_currency=USD&to_currency=JPY&apikey=demo", "{{Realtime Currency Exchange Rate}}")
.
@lucasomigli thanks for presenting your use case since I had not accounted for it in the code! I updated the code to handle dots inside JSON attribute names. As an example for your context, use the following template to get the exchange rate:
{{Realtime Currency Exchange Rate."5. Exchange Rate"}}
As shown above, surround attributes that contain embedded dots with double quotes in your template. I have updated the README documenting this new template syntax as well.