Michael Cruden
 · Seamless Technology Integration

How do I work with this API call as a number not a string?

I am pulling crypto data from an api. The return closes all values in double quotes, which is telling the app that the values are all strings. However, I need to do logic tests on these values, for example: color coding red/green based on +/- values. I calculate something on two of them. No matter what I do, I either have to save them as strings or throw errors trying to work with these values as numbers. Trying to figure out the parse as datatype, but am a bit stuck on how to finish that setup.

Here is the example JSON return I am trying to work with:

"id": "bitcoin",
"symbol": "BTC",
"name": "Bitcoin", 
"priceUsd": "69600.248", **
"changePercent24Hr": "1.731", **

I need to define these items which will be seen as strings due to quotes as type:double. Even if you try and change it, the option to assign a numeric type (double in this case) is not an option.*

*Edit - Could this be a bug? You can set this in single items, just not on lists

Since I couldn't figure out how to do this just with paths, tried to define a data type with 5 fields all named exactly as the name column shows as well. However, I can't figure out how to assign the endpoint return to that data type.

I know assigning type in JSON Paths is a fairly new feature & hoping to learn more. Once I can work with these fields as numerics, things will get a lot easier for me to publish a crucial update & bug fix after our initial launch. I got our app in the app store this last week!

If I could just set this to double, I would be all set:

1
9 replies