Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7959547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:35:27+00:00 2026-06-04T04:35:27+00:00

My problem is really simple but I’m not sure if there’s a native solution

  • 0

My problem is really simple but I’m not sure if there’s a “native” solution using JSON.parse.

I receive this string from an API :

{ "key" : -922271061845347495 }

When I’m using JSON.parse on this string, it turns into this object:

{ "key" : -922271061845347500 }

As you can see, the parsing stops when the number is too long (you can check this behavior here). It has only 15 exact digits, the last one is rounded and those after are set to 0. Is there a “native” solution to keep the exact value ? (it’s an ID so I can’t round it)

I know I can use regex to solve this problem but I’d prefer to use a “native” method if it exists.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T04:35:28+00:00Added an answer on June 4, 2026 at 4:35 am

    Your assumption that the parsing stops after certain digits is incorrect.

    It says here:

    In JavaScript all numbers are floating-point numbers. JavaScript uses
    the standard 8 byte IEEE floating-point numeric format, which means
    the range is from:

    ±1.7976931348623157 x 10308 – very large, and ±5 x 10-324 – very small.

    As JavaScript uses floating-point numbers the accuracy is only assured
    for integers between: -9007199254740992 (-253) and 9007199254740992
    (253)

    You number lies outside the “accurate” range hence it is converted to the nearest representation of the JavaScript number. Any attempt to evaluate this number (using JSON.parse, eval, parseInt) will cause data loss. I therefore recommend that you pass the key as a string. If you do not control the API, file a feature request.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel as though there is a really simple solution to my problem, but
Maybe there is a really simple solution for my problem, but I'm really confused
This may be a really simple question, but I'm not sure what the most
i guess this is a really simple problem, but i just can't get it
This seems like a really, really simple problem, but I can't figure it out.
This should be a really simple problem, but I can't quite figure out what
This may be a really simple problem to some people, but I'm finding it
I'm facing a wordpress / htaccess problem. This should be really simple, but it's
This is probably a really simple problem, but I can't figure out how to
I'm having a problem that i'm sure that it's really simple to solve but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.