Skip to content

Commit

Permalink
Merge pull request #5 from fangq/master
Browse files Browse the repository at this point in the history
Update to new Draft 2
  • Loading branch information
fangq authored Mar 2, 2022
2 parents 398888e + 2464fc4 commit 9ea2d75
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
36 changes: 15 additions & 21 deletions Binary_JData_Specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -455,14 +455,27 @@ array or object) are considered to be of that singular _type_ and, as a result,
_type_ markers are omitted for each value within the container. This can be
thought of as providing the ability to create a strongly-typed container in BJData.

A major different between BJData and UBJSON is that the _type_ in a BJData
strongly-typed container is limited to **non-zero-fixed-length data types**, therefore,
only integers (`i,U,I,u,l,m,L,M`), floating-point numbers (`h,d,D`) and char (`C`)
are qualified. All zero-length types (`T,F,Z,N`), variable-length types(`S, H`)
and container types (`[,{`) shall not be used in an optimized _type_ header.
This restriction is set to reduce the security risks due to potentials of
buffer-overflow attacks using [zero-length markers](https://github.com/nlohmann/json/issues/2793),
hampered readability and dimished benefit using variable/container
types in an optimized format.

The requirements for _type_ are

- If a _type_ is specified, it **must** be one of `i,U,I,u,l,m,L,M,h,d,D,C`.
- If a _type_ is specified, it **must** be done so before a _count_.
- If a _type_ is specified, a _count_ **must** be specified as well. (Otherwise
it is impossible to tell when a container is ending, e.g. did you just parse
*]* or the `int8` value of 93?)

#### Example (string type):
#### Example (uint8 type):
```
[$][S]
[$][U]
```

---
Expand Down Expand Up @@ -579,25 +592,6 @@ Optimized with both _type_ and _count_
// No end marker since a count was specified.
```

---
### Special case: Marker-only types (`null`, `no-op` & Boolean)
If using both _count_ and _type_ optimizations, the marker itself represents the
value, thus saving repetition (since these types do not have a payload).
Additional examples are:

Strongly-typed array of type `true` (Boolean) and with a _count_ of 512:
```
[[][$][T][#][I][512]
```

Strongly-typed object of type `null` and with a _count_ of 3:
```
[{][$][Z][#][i][3]
[i][4][name] // name only, no value specified.
[i][8][password]
[i][5][email]
```

Recommended File Specifiers
------------------------------

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ draft of this file specification, including
question, report a bug, provide a feature request, or simply propose
general discussions. Please use URLs or keywords to link your discussion
to a specific line/section/topic in the document.
- [Write short comments on Request for Comments (RFC) commits](https://github.com/NeuroJSON/bjdata/commit/3f12e5ddaf75863ed9a69714dbd00e1258660118)
- [Write short comments on Request for Comments (RFC) commits](https://github.com/NeuroJSON/bjdata/commit/679e92e45aa3ceae9fb5bc74e469ca8cf504be41)
- A milestone version of the specification will be associated with an
RFC (Request for comments) commit (where the entire file is removed
and re-added so that every line appears in such commit). One can
write short comments as well as post replies on this RFC page.
- The latest stable release is **[Version 1 Draft 2](https://github.com/NeuroJSON/bjdata/tree/Draft_2)**. Please use
[this link](https://github.com/NeuroJSON/bjdata/commit/3f12e5ddaf75863ed9a69714dbd00e1258660118) to comment.
[this link](https://github.com/NeuroJSON/bjdata/commit/679e92e45aa3ceae9fb5bc74e469ca8cf504be41) to comment.
- To add a comment, you need to first register a github account, and then
browse the above RFC page. When hovering your cursor over each line, a
"plus" icon is displayed, clicking it will allow one to comment on a
Expand Down

0 comments on commit 9ea2d75

Please sign in to comment.