Posted Wed, 20 Feb 2013 22:13:51 GMT in reply to
Nathan M. Swan
Reply
On Wed, 20 Feb 2013 21:44:40 GMT, Nathan M. Swan wrote:
Hi all,
Why are there two different types, Bson
and Json
? I think it would make more sense to have a single type ScriptObject
and to/from methods for the various formats (this would make extending it to i.e. a json-compatible subset of YAML really easy).
Are there some incompatibilities between the formats?
Thanks,
NMS
BSON supports a lot more data types than JSON (some of them also very BSON specific, nothing that is really pretty in a generic type) and the Bson
struct also is optimized for allocation-free decoding (i.e. it uses the BSON binary representation in memory and decodes on access). Json
on the other hand uses a normal D type representation internally.
YAML also seems to support more types than JSON (binary data and user defined types). So although all three have JSON as their intersection set, representing them as a single type would cause information loss/ambiguous representation in any of the target formats.