Page 1 of 1

Is 081105004 a number for JSON?

Posted: Mon Oct 05, 2015 12:53 pm
by bhall2001
I happened to take a json file created by easyJson and run it through a JSON lint program. The program reported an error with a number not being a number. The errant data is a UUID created with a simple formula YYMMDDXXX ( JSON object --- "CRN":081105004 ). The UUID can not be changed as it's a data element from an external source that is out of my control.

Livecode's "is a number" returns true for the above. When I read the JSON spec (json.org) I think I'm seeing that if a number starts with a 0 it must have a "." in it and an integer can not start with a 0? Is that the case?

So is 081105004 a number or a string for JSON? Is "put 081105004 is a number" reporting true the correct answer in Livecode?

Just curious,
Bob

Re: Is 081105004 a number for JSON?

Posted: Mon Nov 02, 2015 2:39 pm
by JacobS
Bob,

Yes, you're right. JSON specifications do not allow leading zeros on numbers without a decimal point. See section 8 on page 3 of http://www.ecma-international.org/publi ... MA-404.pdf.

LiveCode doesn't have this restriction on numbers, so when you do

Code: Select all

put 081105004 is a number
it will return true. This is expected.

As far as your issue goes, it seems to me that your UUID is really a string and not a number. If it were truly a number the leading zero wouldn't matter! I'm not sure if you have control over how the UUID is formatted when it is returned from the external source, but it really should be a string.

Hope that helps,
Jacob