The second argument to JSON.stringify is a "replacer" function or array. In
your case, you'd want a function that looks at the value, ascertains if it
is a number, and returns the number converted to a string, e.g., value + "".
The replacer parameter is well-documented at
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Using_native_JSON#The_replacer_parameter
Cheers,
Derrell
On Wed, May 7, 2014 at 4:25 AM, Defero <krosela...@gmail.com> wrote:
> Hi,
>
> i have a question about requests with the server side via json. For local
> testing i'm using jsonp request and on server i use rpc.
> The problem comes from large numbers and javascript.
>
> Imagine this json:
> {
> value : 123456789012.123456789012
> }
>
> On my, qooxdoo side i'm using strings as a representation of numbers. All
> numbers are always strings. That solves the problem while working with
> numbers on my side.
> But the server doesn't communicate numbers as strings, and i can't make it
> to, since it is not in my control.
>
> To solve this problem, i decided to change all the numbers to strings
> before
> they my side has a chance to round them up. So if the server sends me back:
> "{ value : 123456789012.123456789012 }"
> i want to do, BEFORE it is represented as a javascript object this:
> "{value : \"123456789012.123456789012\" }"
>
> and in that case i won't lose big numbers and update the database with
> wrong
> data.
>
> That was the plan but now i'm unsure where to change this so it will work
> in
> such a way. I need to change the response in the "raw string form" before
> it
> is assigned as a js object of the jsonp and rpc requests. And right before
> it is sent to the server (i have to remove the " before i send it to the
> server also).
>
> Is this possible or are there any better solutions? (I can't change what
> the
> server send/expects)
>
> Regards,
> Defero
>
>
>
> --
> View this message in context:
> http://qooxdoo.678.n2.nabble.com/remote-Request-json-and-big-numbers-tp7585656.html
> Sent from the qooxdoo mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Is your legacy SCM system holding you back? Join Perforce May 7 to find
> out:
> • 3 signs your SCM is hindering your productivity
> • Requirements for releasing software faster
> • Expert tips and advice for migrating your SCM now
> http://p.sf.net/sfu/perforce
> _______________________________________________
> qooxdoo-devel mailing list
> qooxdoo-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>
------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel