10649 shaares
356 private links
356 private links
The parsers are different in JS, Python, Go and Java.
Number are not precise:
- MAX_SAFE_INTEGER limits the number. Twitter had to use an `id_str.
- decimal precision is unreliable (in JS) --> always use dedicated decimal types (Python’s Decimal, Java’s BigDecimal, JavaScript’s decimal libraries)
- UTF-8 encoding in JSON allow single unicode code points or composed ones. Use
.normalize("NFC")
for JS strings. - the object key order should be alphabetically in JSON.
- Different languages handle absence of values (
undefined
,null
or a missing property) differently. - No time format is official, so it's always custom:
{ "iso_string": "2023-01-15T10:30:00.000Z", "unix_timestamp": 1673780200, "unix_milliseconds": 1673780200000, "date_only": "2023-01-15", "custom_format": "15/01/2023 10:30:00" }
- Different parsers fail differently on malformed JSON.
The twitter example is only one. There is also postgres that stores the format as JSON and JSONB (normalized).
MongoDB uses an extended JSON format.
Workarounds:
- Use Schema Validation!
- custom normalisation function#:~:text=Normalize%20Data%20Types%3A%20Ender%E2%80%99s%20Data%20Normalization%20Game)
- Tests! Numeric Precision Tests, Unicode and String Handling, Date and Time Consistency, Error Handling Uniformity, Cryptographic Consistency, Performance and Memory Behavior