Forum Discussion

hollingl's avatar
hollingl
Occasional Contributor
9 years ago
Solved

JSON integer property being transferred as a float

I am having some issues transferring a property from a JSON response payload to a subsequent REST call. I have two REST calls and between them a property transfer of an integer value in the payload to a URL parameter. While the value in the JSON is {"id":14}, it is being mapped into the target URL as /14.0/ - which my REST service rejects.

 

I understand that numbers are intrinsically floating point in JS(ON), but was wondering if there was any way I could apply a cast or truncation as part of the property transfer?

 

I am on SoapUI OS 5.2.1 on Windows 10.

4 Replies

  • nmrao's avatar
    nmrao
    Champion Level 3

    It depends on the schema / data type.
    You can easily change it.

    def value = 14.0
    def transformedValue = value as Integer
    assert transformedValue instanceof java.lang.Integer