The "numberFormat" property is an optional enumerated string that defines the format of JSON numbers. The default value for "numberFormat" is the "defaultNumberFormat" defined in the "createSession" or "alterSession" actions. If it is omitted there, it defaults to the value of the "defaultNumberFormat" property in the <faircom>/config/services.json file.
When "numberFormat" occurs in "mapOfPropertiesToFields", it tells the server how to encode or decode a number assigned to a JSON property.
For example, including "numberFormat" in a "tableFieldsToJson" transform step controls if the server encodes a number in a JSON property as a number or a number embedded in a string.
Possible values:
-
"number"(default)- This causes the server to return numeric values as JSON numbers, such as
-18446744073709551616.000144722494. - This is most efficient.
- JSON represents numbers are base-ten numbers that may have any number of digits.
- Large numbers, such as
18446744073709551616.000144722494are known to cause problems with JSON parsers and some programming languages, such as JavaScript, which are limited to the smaller range and binary rounding errors of IEEE floating point numbers.
- This causes the server to return numeric values as JSON numbers, such as
-
"string"- This returns the server to embed numeric values in JSON strings, such as
"18446744073709551616.000144722494". - This is slightly less efficient because it includes two extra double quote characters
- Returning numbers embedded in strings ensures JSON parsers and programming languages will not automatically convert the number to a numeric representation that loses precision, introduces rounding errors, truncates values, or generates errors. This allows your application to control how numbers are processed.
- This returns the server to embed numeric values in JSON strings, such as
- Omitted or set to
null- This defaults to
"number".
- This defaults to
Example request
{
"action": "someAction",
"responseOptions":
{
"numberFormat": "string"
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}