Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-13868

Spin jsonPath method uses Float as default data type for Number node

XMLWordPrintable

    • Icon: Bug Report Bug Report
    • Resolution: Unresolved
    • Icon: L3 - Default L3 - Default
    • None
    • None
    • engine, spin

      Environment (Required on creation):

      • Camunda 7.15.3-ee

      Description (Required on creation; please attach any relevant screenshots, stacktraces, log files, etc. to the ticket):

      When dealing with bigger floating-point numbers, using Spin's "jsonPath" method on a JSON object leads to unexpected rounding behavior.

      Steps to reproduce (Required on creation):

      Sample test case is attached for reference:

      1. Create a Script Task ("javascript" format) reading floating point JSON property via Spin's "jsonPath" method, for example:
        var response2 = execution.getVariable("response")
        var query = "$.value"
        S(response2).jsonPath(query).numberValue()
        
      1. Start an instance with a variable of type String which contains a JSON. The JSON should contain a numeric property as shown below.
          Map<String, Object> variables = new HashMap<>();
          String var = "{\"id\":\"testid\",\"value\":\"234302.13\"}";
          variables.put("response", var);
          runtimeService.startProcessInstanceByKey("sample1", variables);
        

      Observed Behavior (Required on creation):

      The value returned by jsonPath.numberValue() is 234302.12 instead of 234302.13

      Expected behavior (Required on creation):

      The value returned by jsonPath.numberValue() should match the numeric value of property in JSON i.e. 234302.13

      Root Cause (Required on prioritization):

      JacksonJsonPathQuery is returned by S(response).jsonPath(query) method. If the input parameter is an instance of Number, we create a JSON node with a Float value. Here is the code for reference: https://github.com/camunda/camunda-spin/blob/b2d72eb8a83887d78009011d17667d0c73542b99/dataformat-json-jackson/src/main/java/org/camunda/spin/impl/json/jackson/format/JacksonJsonDataFormat.java#L238

      Solution Ideas (Optional):

      Create Double nodes in case of abstract Number nodes. This is also consistent with how Jackson operates by default when using our "prop" methods.

      Hints (Optional):

        This is the controller panel for Smart Panels app

              Unassigned Unassigned
              garima.yadav Garima Yadav
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated: