Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
json
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
0 deletions
+14
-0
binary_writer.hpp
include/nlohmann/detail/output/binary_writer.hpp
+6
-0
json.hpp
single_include/nlohmann/json.hpp
+6
-0
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