afw-org / afw

Adaptive Framework
https://afw.tools
MIT License
4 stars 1 forks source link

JSON <-> Adaptive Objects #70

Open mike000000000 opened 11 months ago

mike000000000 commented 11 months ago

JSON does not support Infinity, NaN and undefined. Also, an integer is handled differently by Adaptive Script and ECMAScript.

If there is an object type associated with a JSON object, we can use property dataType to aid in supporting these.

If a property has a dataType of double, the JSON strings "Infinity", "-Infinity" and "NaN" should be used.

For an adaptive object, properties with an undefined value should not be included in JSON objects.

For an adaptive array, entries that are undefined value should be represented with JSON null. This should work out since most arrays hold one of the adaptive data types and JSON null is as unique a way as any to specify a JSON value not of that data type to indicate 'undefined'. (Question: Should objects work this way too?)

JSON number with only the integer part should be used for data type integer. Any JSON number with fraction or exponent, as well at JSON string "Infinity", "+Infinity", "-Infinity", "NaN', "+NaN", and "-NaN", should represent double.

ECMAScript stuffs all numbers into double so integer > 2**53-1 are inaccurate and all divides are floating point divides instead of integer divides, which is also not accurate. As of ES2020, BigInt is part of the ECMAScript standard, so maybe it should be used for integers?

Adaptive Framework supports integer between -263 and 263-1. It this becomes an issue, Adaptive Framework should be changed to support a wider range.