My API endpoint returns a few numbers/ints as json...
# getting-started
j
My API endpoint returns a few numbers/ints as json strings like
{"value":"12.6"}
; doesn’t look like setting the schema to NumberType try to cast that and it’s exporting as a string. That’s really the only modification of the response that needs to be done. What’s a good method to handle that?
Github comments seem to suggest it should be cast appropriately already/recursively. Humm
Using the post process step I was able to do a
row["myfield"] = float(row["myfield"])
; is there a better way? It’s of th.NumberType but wasn’t being converted automatically.
v
I'd leave it as a string if that's how the API is giving you the data. Yes post process is a good spot for transformations. Converting to float is not precise, converting to a numeric is more but I wouldn't do that in the tap
e
If you absolutely want the value to be serialized as a float in the tap's output, you can use
post_process
to cast it to a decimal.Decimal.