5 ms·
Since JSON is so widely used it should be modified to support more types - Mongo DB's Extended JSON supports all the BSON (Binary) types: Array Binary
by ape4 3y ago
Since JSON is so widely used it should be modified to support more types - Mongo DB's Extended JSON supports all the BSON (Binary) types:
Array
Binary
Date
Decimal128
Document
Double
Int32
Int64
MaxKey
MinKey
ObjectId
Regular Expression
Timestamp
https://www.mongodb.com/docs/manual/reference/mongodb-extended-json/ https://www.mongodb.com/docs/manual/reference/mongodb-extend...
- bterlson 3y agoJS is likely to get a hook to be able to handle serialization/deserialization of such values without swapping out the entire implementation[1]. Native support for these types, without additional code or configuration, would likely break the Internet badly, so is unlikely to happen unfortunately. 1: https://github.com/tc39/proposal-json-parse-with-source https://github.com/tc39/proposal-json-parse-with-source
- apantel 3y agoMuch more valuable than any such extension would be a way to annotate types and byte lengths of keys and values so that parsers could work more efficiently. I’ve spent a lot of time making a fast JSON parser in Java and the thing that makes it so hard is you don’t know how many bytes anything is, or what type. It’s hard to do better than naive byte-by-byte parsing.
- your_fin 3y agoIf you control the underlying data, I must reccomend Amazon Ion! Its text format is a strict superset of JSON, but they also maintain binary format that will round-trip data and is designed for efficient scanning. There's even prefixed annotations if you want them :) It also specs proper decimal values, mitigating the issues presented in the OP. https://amazon-ion.github.io/ion-docs/ https://amazon-ion.github.io/ion-docs/
- zilti 3y agoOr maaaybe use XML for such cases
- Dylan16807 3y agoJSON is not the place to be so fussy about number widths, and things like MaxKey and 24-hex-value ObjectId would be ridiculous.