Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
json
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
json
Commits
a10d486e
Unverified
Commit
a10d486e
authored
Jul 17, 2020
by
Niels Lohmann
Committed by
GitHub
Jul 17, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2244 from matthewbauer/tag-cbor
Tag binary values in cbor if set
parents
e65cc9dc
dd08f770
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
0 deletions
+14
-0
include/nlohmann/detail/output/binary_writer.hpp
include/nlohmann/detail/output/binary_writer.hpp
+6
-0
single_include/nlohmann/json.hpp
single_include/nlohmann/json.hpp
+6
-0
test/src/unit-cbor.cpp
test/src/unit-cbor.cpp
+2
-0
No files found.
include/nlohmann/detail/output/binary_writer.hpp
View file @
a10d486e
...
...
@@ -279,6 +279,12 @@ class binary_writer
case
value_t
:
:
binary
:
{
if
(
j
.
m_value
.
binary
->
has_subtype
())
{
write_number
(
static_cast
<
std
::
uint8_t
>
(
0xd8
));
write_number
(
j
.
m_value
.
binary
->
subtype
());
}
// step 1: write control byte and the binary array size
const
auto
N
=
j
.
m_value
.
binary
->
size
();
if
(
N
<=
0x17
)
...
...
single_include/nlohmann/json.hpp
View file @
a10d486e
...
...
@@ -12795,6 +12795,12 @@ class binary_writer
case
value_t
:
:
binary
:
{
if
(
j
.
m_value
.
binary
->
has_subtype
())
{
write_number
(
static_cast
<
std
::
uint8_t
>
(
0xd8
));
write_number
(
j
.
m_value
.
binary
->
subtype
());
}
// step 1: write control byte and the binary array size
const
auto
N
=
j
.
m_value
.
binary
->
size
();
if
(
N
<=
0x17
)
...
...
test/src/unit-cbor.cpp
View file @
a10d486e
...
...
@@ -2503,6 +2503,8 @@ TEST_CASE("examples from RFC 7049 Appendix A")
std
::
vector
<
uint8_t
>
expected
((
std
::
istreambuf_iterator
<
char
>
(
f_bin
)),
std
::
istreambuf_iterator
<
char
>
());
CHECK
(
j
==
json
::
binary
(
expected
));
CHECK
(
json
::
to_cbor
(
json
::
binary
(
std
::
vector
<
uint8_t
>
{},
0x42
))
==
std
::
vector
<
uint8_t
>
{
0xd8
,
0x42
,
0x40
});
}
SECTION
(
"arrays"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment