Monte Goulding's day off? ; -) mergJSON - Documented Bug or Feature?

Lagi Pittas iphonelagi at gmail.com
Wed Jun 29 12:57:18 EDT 2016


Hi darr

I think the upshot of this conversation is that Monte used a C library for
the JSON  that followed the JSON documentation to the letter, whether the
letter made practical sense.
If this is what Doug Crockford envisaged well there is another God we have
to stop worshiping ;-).

update

Just read through https://www.rfc-editor.org/rfc/rfc7158.txt

And nowhere can I see  it stipulate  that it has to be read  or written to
the maximum number of digits of precision, only that the precision can be
implementation dependent.

So we can thank (or not)  the creator of the C-library that Monte used for
the illogical (IMHO) way it works.

Anyway Darr - it seems your JSON library is needed so we can make our own
tweaks if need be - but I bet it works the way I envisage it here.

Regards Lagi

p.s. Don't get me wrong it's not a problem to do the rounding, but if I
hand build a JSON file with 1.40 , 1.20, etc in it and I read and then
output it again I expect the data to remain the same. Same with CSV same
with a livecode script.


On 29 June 2016 at 17:11, Dar Scott <dsc at swcp.com> wrote:

> I'm coming in this late and I'm confused.
>
> I made a JSON library a couple years ago (not an external) and I have been
> encouraged to make it available, but with JSON now being built-in, I didn't
> bother.  Now, there is MergJSON?
>
>
> > On Jun 29, 2016, at 9:06 AM, Mark Waddingham <mark at livecode.com> wrote:
> >
> > On 2016-06-29 16:58, Lagi Pittas wrote:
> >> Hi Mark,
> >> Thanks for the replies. But your second response I don't understand and
> the
> >> whole point of what I was getting at.
> >> "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."
> >> If  "reals" are returned as  strings anyway then if the real says 2.30
> how
> >> can I be losing any precision if 2.30 is what's in the file?. The option
> >> though would be a good idea but in the calling routine to MergJSON.. If
> it
> >> is left blank or false then it uses the current setting of number format
> >> or if there is a string then that will be the format it uses.
> >
> > Ah - this is the critical point...
> >
> > MergJSON uses a C library which converts the text of a JSON input into a
> tree of values - these values are arrays, objects, numbers, strings,
> booleans etc. i.e. The output of this library is then processed by the
> external to convert it to a LiveCode array and string values...
> >
> > This means that the external gets numbers from the JSON as IEEE754
> doubles, and then has to format them for return as strings. As the original
> string has already been converted to a number at this point, the external
> must format the numbers with enough decimal places so that you don't lose
> any information. Hence why you are probably best off processing the output
> of the external in LiveCode Script, rounding any numbers you know need to
> be rounded.
> >
> >> If I look at the Arrays using the variable display in the debugger they
> are
> >> all showing as 2 decimals so I would expect them to export in the same
> >> format - or am I again missing something about the debugger?
> >
> >> If added  global variable xx in the debugger with value 1.3456 and that
> is
> >> how it shows and ll 2 decimal place prices still show the same so LC
> >> "knows" how I want to see them.
> >
> > The debugger displayed values using the numberFormat settings - usually
> 6 decimal places.
> >
> > However, an important thing to remember about LiveCode Script is that if
> something is a string, then it will remain a string. You only get actually
> numbers internally when you perform operations on values which need to be
> numbers. So:
> >
> >    put 1.43858239402803492304
> >
> > will display:
> >
> >    1.43858239402803492304
> >
> > But:
> >
> >   put 1.43858239402803492304 + 0
> >
> > will display:
> >
> >   1.438582
> >
> > As numbers are rounded using numberFormat when converted to strings.
> >
> > Warmest Regards,
> >
> > Mark.
> >
> > --
> > Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
> > LiveCode: Everyone can create apps
> >
> > _______________________________________________
> > use-livecode mailing list
> > use-livecode at lists.runrev.com
> > Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> > http://lists.runrev.com/mailman/listinfo/use-livecode
> >
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list