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
dad4916f
Commit
dad4916f
authored
Jul 12, 2017
by
Niels Lohmann
Committed by
GitHub
Jul 12, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #654 from ryanjmulder/develop
add ensure_ascii parameter to dump. #330
parents
7dee868a
486f3a2d
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
41 deletions
+76
-41
src/json.hpp
src/json.hpp
+64
-39
test/src/unit-convenience.cpp
test/src/unit-convenience.cpp
+5
-2
test/src/unit-inspection.cpp
test/src/unit-inspection.cpp
+7
-0
No files found.
src/json.hpp
View file @
dad4916f
This diff is collapsed.
Click to expand it.
test/src/unit-convenience.cpp
View file @
dad4916f
...
...
@@ -50,11 +50,12 @@ TEST_CASE("convenience functions")
SECTION
(
"string escape"
)
{
const
auto
check_escaped
=
[](
const
char
*
original
,
const
char
*
escaped
)
const
char
*
escaped
,
const
bool
ensure_ascii
=
false
)
{
std
::
stringstream
ss
;
json
::
serializer
s
(
nlohmann
::
detail
::
output_adapter_factory
<
char
>::
create
(
ss
),
' '
);
s
.
dump_escaped
(
original
);
s
.
dump_escaped
(
original
,
ensure_ascii
);
CHECK
(
ss
.
str
()
==
escaped
);
};
...
...
@@ -97,5 +98,7 @@ TEST_CASE("convenience functions")
check_escaped
(
"
\x1d
"
,
"
\\
u001d"
);
check_escaped
(
"
\x1e
"
,
"
\\
u001e"
);
check_escaped
(
"
\x1f
"
,
"
\\
u001f"
);
check_escaped
(
"
\xA9
"
,
"
\xA9
"
);
check_escaped
(
"
\xA9
"
,
"
\\
u00a9"
,
true
);
}
}
test/src/unit-inspection.cpp
View file @
dad4916f
...
...
@@ -250,6 +250,13 @@ TEST_CASE("object inspection")
CHECK
(
json
(
"❤️"
).
dump
()
==
"
\"
❤️
\"
"
);
}
SECTION
(
"dump with ensure_ascii and non-ASCII characters"
)
{
CHECK
(
json
(
"ä"
).
dump
(
-
1
,
' '
,
true
)
==
R"("\u00c3\u00a4")"
);
CHECK
(
json
(
"Ö"
).
dump
(
-
1
,
' '
,
true
)
==
R"("\u00c3\u0096")"
);
CHECK
(
json
(
"❤️"
).
dump
(
-
1
,
' '
,
true
)
==
R"("\u00e2\u009d\u00a4\u00ef\u00b8\u008f")"
);
}
SECTION
(
"serialization of discarded element"
)
{
json
j_discarded
(
json
::
value_t
::
discarded
);
...
...
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