Set serialization options for JSON in a server workflow
There is one extremely annoying thing in server workflows, and that is that the JSON serializer adds decimals to number values. E.g. when using this value as the JSON parameter in a Web Request:
={
"test":1
}the request's body will be:
{"test":1.0}
It appears that there are several 3rd party API's that do not like decimals in numeric values. The only workaround I can think of is to use Convert To JSON (Which has the same problem), and manipulate the string value using a reqular expression. This is ugly.
Please strip trailing zeroes from numbers automatically, or provide an option to do so.
@VertiGIS: Here is the support request I made 2 years ago
-
It might be something to do with the data type of the number.
I tested the .NET version of Convert To Json and found that 1 (integer) and 1.0 (double) both serialized to 1 but 1.0m (decimal) serialized to 1.0.
In a Server Workflow, you could use the Convert Value to ArcGIS Field Type activity to ensure a value is the desired numeric type. Hopefully that can suppress the “.0” ending in the serialization.
0 -
I spoke too soon. It looks like issue 361582 may have fixed this already in 5.50?
0 -
Yes, that certainly looks like the scenario you're describing.
0
Du måste logga in om du vill lämna en kommentar.
Kommentarer
3 kommentarer