0

I am trying to read a Double data-type value from a JSON payload using the property mediator.

<property expression="json-eval($.totalPrice)" name="TOTAL_PRICE" scope="default" type="DOUBLE"/>

But I get the following error:

Unknown type : DOUBLE for the property mediator or the property value cannot be converted into the specified type. java.lang.NumberFormatException: empty String

How can I get its value?

ycr
  • 12,828
  • 2
  • 25
  • 45
Ruby
  • 368
  • 1
  • 9
  • Why are you reading this as a DOUBLE instead of a STRING? – ycr Jul 22 '22 at 18:19
  • Because the data type of totalPrice in json payload is set to Double. – Ruby Jul 22 '22 at 18:21
  • After extracting what do you do with this value? – ycr Jul 22 '22 at 18:23
  • We log it. I tried using STRING in place of DOUBLE, but it prints nothing – Ruby Jul 22 '22 at 18:25
  • 1
    You are getting that error because your are trying to convert an empty String to a Double. Are you passing a value for `totalPrice`? If so may be your Json path is incorrect. The bottom line is, this `json-eval($.totalPrice)` is returning an empty string. – ycr Jul 22 '22 at 18:31
  • I'll recheck with my json payload and path expression. – Ruby Jul 22 '22 at 18:40
  • 1
    Yup, as you said the json payload we were receiving from the endpoint was not validated. Due to unbalanced paranthesis in the json payload, the expression was not working. As it was coming from an endpoint I thought it would be valid one. Did not think about validating it. Thanks for your help – Ruby Jul 22 '22 at 19:15

0 Answers0