Monte Goulding's day off? ;-) mergJSON - Documented Bug or Feature?
mark at livecode.com
Wed Jun 29 08:39:46 EDT 2016
On 2016-06-29 14:21, Mark Waddingham wrote:
> On 2016-06-29 13:22, Lagi Pittas wrote:
>> Can someone please explain the logic that says that a textual
>> representation of information (CSV, XML a text file even) is
>> translated to
>> a IEEE number for us to round as we see fit?
Apologies - you can ignore all that I wrote in my previous response - I
had forgotten that mergJSON is an old-style external so can only return
The C library it uses returns values in bools, ints, doubles and strings
(at the C level). However, to return this data to LC it has to format
all of these as strings (this is a limitation of the old externals
interface). Therefore, it renders numbers in a form where you will not
lose any information - i.e. with 16 decimal places. This is the best way
to ensure you can then round them to a precision of your choice - hence
you see what you see.
I suppose there could be an option to choose a 'number of decimal
places' option passed to the library - however, you will then
potentially lose information in your numbers. Therefore, it is probably
better to do the rounding in script after loading the JSON file.
An alternative is to look at the JSON LCB library - this returns values
as actual numbers, booleans and strings to LiveCode - which means that
the numbers (in particular) get converted to strings respecting the
numberFormat property currently in effect.
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps
More information about the Use-livecode