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

  • SEARCH
  • Home
  • 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 8395695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:21:57+00:00 2026-06-09T20:21:57+00:00

As JavaScript uses floating point maths for all numbers, which does not preserve precision

  • 0

As JavaScript uses floating point maths for all numbers, which does not preserve precision in all cases, I want to parse a JSON object containing numbers but generate strings in the returned JavaScript object rather than number objects. Is there a way to do this using standard or third party libraries?

  • 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-09T20:21:59+00:00Added an answer on June 9, 2026 at 8:21 pm

    You can do something like this. This may not be a perfect solution (especially the reg expression), but hope it will help you to solve this.

    var json = '{"num1":123.89075576575775676575, "num2":89.5564764646476444844, "num3":56.4353454354353535435435435}';
    
    json = json.replace(/\d+.\d+/g, function(a, b){ 
        return '\"' + a + '\"';
    });
    
    console.log($.parseJSON(json )); // I have used jQuery. Any JSON parser can be used
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://support.xbox.com/en-us/contact-us uses javascript to create some lists. I want to be able to parse
My app uses javascript to generate all the HTML for my website. The index.html
I have a tiny javascript which uses JQUERY UI. When I get the 'drop'
At the moment i have a stylesheet switcher which uses javascript to to load
I am developing a user control (ascx) in ASP.NET which uses javascript for manipulating
I have a simple .html page which uses Javascript to display some popups. Now
I am building a site which currently uses javascript from several sources: Group 1:
I've created a dot graph with CSS that uses JavaScript to do all the
Suppose I have a hex number 4072508200000000 and I want the floating point number
I have a simple javascript that uses $.ajax() from JQuery which works great for

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.