0

i am using JSON.stringify() function in JSR223post processor to capture the response in jmeter. but it is trimming the decimal points from the response.

suppose Quanity: 120.000 will be there in actual response but my function is taking only 120. could anyone help on this

  • See https://stackoverflow.com/questions/41624332/how-to-keep-value-as-number-in-json-stringify – Ori Marko Sep 22 '21 at 09:43
  • Does this answer your question? [How to keep value as number in JSON.stringify()](https://stackoverflow.com/questions/41624332/how-to-keep-value-as-number-in-json-stringify) – Philip Wrage Sep 30 '21 at 21:07

1 Answers1

0
  1. Looking into JSON.stringify() function documentation it doesn't seem that you can control the way of numeric values serialization

  2. Using JavaScript is kind of a performance anti-pattern, you should be using Groovy language, take a look at Apache Groovy - Parsing and producing JSON article

    enter image description here

If you have to use JavaScript for any reason you can try parseFloat() and toFixed() functions

enter image description here

Dmitri T
  • 159,985
  • 5
  • 83
  • 133