einuye / proposals

Nerine proposals and RFCs.
Apache License 2.0
2 stars 0 forks source link

JSON Datatype (through BSON) #1

Open bernkastel02 opened 3 years ago

bernkastel02 commented 3 years ago

RFC0001 - JSON Datatype (through BSON)

RFC Stage: Stage 1

Introduction and Summary

BSON exists as a sustainable datatype for storing JSON as binary, serializing it into a format we can store at pure ease. JSON has proven to be an important storage necessity for things like settings, configuration and more.


Adding support for JSON through this format will allow users to store JSON objects and values sustainably, without having to use an external format for such.

Explanation

BSON examples are well provided as is, and can be used by individual database implementations to create their own parser (unless they use a module in their individual languages)

For example, this is a BSON data structure.

 Document Size      Type   Field Name       Value Size    Value            Null Terminator   End of Object
 16 00 00 00        02     68 65 6C 6C 6F   06 00 00 00   77 6F 72 6C 64   00                00
 0                  4      5                10            14               19                20

This can be deserialized into the provided JSON structure:

{
    "hello": "world"
}

With this nice, simple look; It would fit right in with how data is formatted.

Pseudo-code

# BSON Example
  \x16\x00\x00\x00               // total document size
  \x02                           // 0x02 = type String
  hello\x00                      // field name
  \x06\x00\x00\x00world\x00      // field value (size of value, value, null terminator)
  \x00                           // 0x00 = type EOO ('end of object')

Rationale and Alternatives

Metadata

Current Implementations

This section is reserved for whenever a database implementation adds it.

Timeline

3/2/2020 - Created RFC

SMJSGaming commented 3 years ago

Seems like a good idea to add large scale support for object storing. Personally I think BJSON would be the better option here as it should in theory be closer to the format of all the other implemented types/blocks.

bernkastel02 commented 3 years ago

UBJSON would work too, if it's actually any close to finished.

bernkastel02 commented 3 years ago

oh image

guess that's a no then; guess we should consider removing it as an option for an alternative

bernkastel02 commented 3 years ago

it's probably fine to move this to stage 1 considering all aspects of it are defined and it's been nearly a week since it's creation