I have an API endpoint that returns JSON. One of the fields is a number with one digit to the right of the decimal point. We need to verify that the value is correct with the correct precision.
If the digit to the right of the decimal point is anything other than 0, the comparison works find using a JSON path match. If the digit is a 0 however, the value seems to be cast to an int, either when the JSON is parsed or inside the assert.
JSON snippet:
"registerableInstances" : [ { "subjectCode" : "10", "subjectNumber" : "02", "percentContribution" : 15.0, "departmentCode" : "10", "sortKey" : "000.010.00.0000.0200.2.000", "primary" : false, "displayNumber" : "10.02" }...
Assert failure message:
-> Comparison failed for path [registerableInstances[0].percentContribution], expecting [15.0], actual was [15]
I also tried a regex match but this failed as well.
Does anyone know a way to force the value to be treated as a float or a string? Or is there any other workaround?
Using Ready API 1.4.1.
Thanks.