Search code examples
javascriptjsonstringify

Reshape API response object from strings to numerical values in JavaScript?


I am working with the Alpha Vantage API on RAPID API and the schema of the response object I am getting from the API is as follows:

Rapid API JSON response object

I am passing this object to a chart, so I need the " " marks around the numerical values in the key-value pairs removed so the chart can use the data. Is there an easy way to do this? I have googled for a JavaScript function that does the opposite of the Stringify function, but so far no luck. Any ideas would be a big help!

The API response JSON object schema is as follows: API response object schema

If it helps, here is the API I am querying: https://rapidapi.com/alphavantage/api/alpha-vantage?endpoint=apiendpoint_55220bb2-8a64-4cde-89e1-87ec00947f57


Solution

  • You can either use Number() function or multiply by 1

    e.g.

    "999.887" * 1 = 999.887