• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..13-Aug-2020-

deprecated/H13-Aug-2020-130127

README.mdH A D13-Aug-20203.4 KiB9768

array.jsonH A D13-Aug-20201.6 KiB4443

binary.jsonH A D13-Aug-20203.7 KiB8685

boolean.jsonH A D13-Aug-2020685 2827

code.jsonH A D13-Aug-20202.4 KiB6867

code_w_scope.jsonH A D13-Aug-20203.5 KiB7978

datetime.jsonH A D13-Aug-20201.4 KiB3736

dbpointer.jsonH A D13-Aug-20202.8 KiB5756

dbref.jsonH A D13-Aug-20201.9 KiB3231

decimal128-1.jsonH A D13-Aug-202017.6 KiB318317

decimal128-2.jsonH A D13-Aug-202037.9 KiB794792

decimal128-3.jsonH A D13-Aug-202088.7 KiB1,7721,771

decimal128-4.jsonH A D13-Aug-20207 KiB166164

decimal128-5.jsonH A D13-Aug-202022.8 KiB403401

decimal128-6.jsonH A D13-Aug-20203 KiB132131

decimal128-7.jsonH A D13-Aug-202012.5 KiB328327

decode-dump.plH A D13-Aug-2020788 4029

document.jsonH A D13-Aug-20201.2 KiB3736

double.jsonH A D13-Aug-20203.5 KiB8887

encode-dump.plH A D13-Aug-2020772 3929

int32.jsonH A D13-Aug-20201.4 KiB4443

int64.jsonH A D13-Aug-20201.5 KiB4443

maxkey.jsonH A D13-Aug-2020275 1312

minkey.jsonH A D13-Aug-2020275 1312

multi-type-deprecated.jsonH A D13-Aug-20205.3 KiB1614

multi-type.jsonH A D13-Aug-20202.4 KiB1211

null.jsonH A D13-Aug-2020258 1312

oid.jsonH A D13-Aug-2020914 2928

regex.jsonH A D13-Aug-20203.1 KiB6665

string.jsonH A D13-Aug-20202.7 KiB7372

symbol.jsonH A D13-Aug-20203.2 KiB8180

timestamp.jsonH A D13-Aug-20201.1 KiB3029

top.jsonH A D13-Aug-20209.2 KiB237235

undefined.jsonH A D13-Aug-2020425 1615

README.md

1# BSON Corpus
2
3This BSON test data corpus consists of a JSON file for each BSON type, plus
4a `top.json` file for testing the overall, enclosing document.
5
6Top level keys include:
7
8* `description`: human-readable description of what is in the file
9* `bson_type`: hex string of the first byte of a BSON element (e.g. "0x01"
10  for type "double"); this will be the synthetic value "0x00" for `top.json`.
11* `test_key`: name of a field in a `valid` test case `extjson` document
12  should be checked against the case's `string` field.
13* `valid` (optional): an array of valid test cases (see below).
14* `decodeErrors` (optional): an array of decode error cases (see below).
15* `parseErrors` (optional): an array of type-specific parse error case (see
16  below).
17
18Valid test case keys include:
19
20* `description`: human-readable test case label.
21* `subject`: an (uppercase) big-endian hex representation of a BSON byte
22  string.  Be sure to mangle the case as appropriate in any roundtrip
23  tests.
24* `string`: (optional) a representation of an element in the `extjson`
25  field that can be checked to verify correct extjson decoding.  How to
26  check is language and bson-type specific.
27* `extjson`: a document representing the decoded extended JSON document
28  equivalent to the subject.
29* `decodeOnly` (optional): if true, indicates that the BSON can not
30  roundtrip; decoding the BSON in 'subject' and re-encoding the result will
31  not generate identical BSON; otherwise, encode(decode(subject)) should be
32  the same as the subject.
33
34Decode error cases provide an invalid BSON document or field that
35should result in an error. For each case, keys include:
36
37* `description`: human-readable test case label.
38* `subject`: an (uppercase) big-endian hex representation of an invalid
39  BSON string that should fail to decode correctly.
40
41Parse error cases are type-specific and represent some input that can not
42be encoded to the `bson_type` under test.  For each case, keys include:
43
44* `description`: human-readable test case label.
45* `subject`: a text or numeric representation of an input that can't be
46  encoded.
47
48## Extended JSON extensions
49
50The extended JSON documentation doesn't include extensions for all BSON
51types.  These are supported by `mongoexport`:
52
53    # Javascript
54    { "$code": "<code here>" }
55
56    # Javascript with scope
57    { "$code": "<code here>": "$scope": { "x":1, "y":1 } }
58
59    # Int32
60    { "$numberInt": "<number>" }
61
62However, this corpus extends JSON further to include the following:
63
64    # Double (needed for NaN, etc.)
65    { "$numberDouble": "<value|NaN|Inf|-Inf>" }
66
67    # DBpointer (deprecated): <id> is 24 hex chars
68    { "$dbpointer": "<id>", "$ns":"<namespace>" }
69
70    # Symbol (deprecated)
71    { "$symbol": "<text>" }
72
73## Visualizing BSON
74
75The directory includes a Perl script `bsonview`, which will decompose and
76highlight elements of a BSON document.  It may be used like this:
77
78    echo "0900000010610005000000" | perl bsonview -x
79
80## Open Questions
81
82These issues are still TBD:
83
84* Can "-0.0" be represented "canonically" in bson?  Some languages might
85  not round-trip it.  (Do we need a "lossy_bson" field to capture this?)
86
87* How should DBPointer round-trip? Should we expect it to be turned into a
88  DBRef or round-trip faithfully?
89
90* How should Symbol roundtrip?  Should we expect it to be turned into a
91  string?
92
93* How should Undefined roundtrip? Should we expect it to be turned into a
94  null?
95
96* Should we flag cases where extjson is lossy compared to bson?
97