Viewing 0 reply threads
Viewing 0 reply threads
- The topic ‘How to cast fields as strings, integers, or floats in rawdata API’ is closed to new replies.
Often we’re asked how to cast a field as a string, integer or float using the rawdata API
The first step is to transform the data field that you want to request data for.
This is done inside the fields param, by writing the new value, followed by :@
and the field to transform, finally to cast it as a separate type you can do __str
, __int
, __float
for string, integer, and float casting respectively.
Thus for casting the latitude as a string it would be:
&fields=latitude_string:@lat__str results in: "latitude_string": "4.696300000000001",
To get the value as an integer you’ll need to also multiply it by 100000 first,
&fields=latitude_float:(@lat__float*100000) results in: "latitude_float": 469630.0000000001,
Finally to get rid of any decimals you can round the value.
&fields=latitude_integer_rounded:(@lat__float*100000).round(0), results in: "latitude_integer_rounded": 469630,
Full example
email: support@digitalcomtech.com
slack: DCT Support Channel
chat: DCT Main Page
developer chat: Gitter
Thank you for Signing Up |
*Entering your email address in this form indicates that you agree to our Privacy Policy. You can withdraw your consent at any time.