PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, August 12, 2022

[FIXED] How to get all decimal digits provided in a json response in Postman?

 August 12, 2022     decimal, postman, postman-collection-runner     No comments   

Issue

I Have an API that returns the following (example):

{"rate": 3.568640920671274015}

In the Tests space, I try to retrieve the rate value:

pm.test("Set variables", function () {
var jsonData = pm.response.json(); 
pm.environment.set('new-rate', jsonData.rate);

But as result, I get only:

3.568640920671274

It seems that Postman is truncating the result. Is there a way to avoid that?

PS: The value came from a decimal. (inside de API).


Solution

Doing something like this:

pm.environment.set('new-rate', jsonData.rate.toPrecision(18));

worked to me.



Answered By - Totalys
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing