Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
ec9e6e05
Commit
ec9e6e05
authored
Aug 26, 2018
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support decoding unicode escapes in JSON strings.
parent
b40445e7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
2 deletions
+9
-2
json-test.c++
c++/src/capnp/compat/json-test.c++
+3
-0
json.c++
c++/src/capnp/compat/json.c++
+6
-2
No files found.
c++/src/capnp/compat/json-test.c++
View file @
ec9e6e05
...
...
@@ -282,6 +282,9 @@ KJ_TEST("decode all types") {
CASE
(
R"({"structField":{"boolField":true}})"
,
root
.
getStructField
().
getBoolField
()
==
true
);
CASE
(
R"({"enumField":"bar"})"
,
root
.
getEnumField
()
==
TestEnum
::
BAR
);
CASE_NO_ROUNDTRIP
(
R"({"textField":"foo\u1234bar"})"
,
kj
::
str
(
"foo\u1234bar"
)
==
root
.
getTextField
());
CASE_THROW_RECOVERABLE
(
R"({"structField":null})"
,
"Expected object value"
);
CASE_THROW_RECOVERABLE
(
R"({"structList":null})"
,
"Expected list value"
);
CASE_THROW_RECOVERABLE
(
R"({"boolList":null})"
,
"Expected list value"
);
...
...
c++/src/capnp/compat/json.c++
View file @
ec9e6e05
...
...
@@ -828,9 +828,13 @@ private:
}
}
// TODO(soon): Support at least basic multi-lingual plane, ie ignore surrogates.
KJ_REQUIRE
(
codePoint
<
128
,
"non-ASCII unicode escapes are not supported (yet!)"
);
if
(
codePoint
<
128
)
{
target
.
add
(
0x7f
&
static_cast
<
char
>
(
codePoint
));
}
else
{
// TODO(perf): This is sorta malloc-heavy...
char16_t
u
=
codePoint
;
target
.
addAll
(
kj
::
decodeUtf16
(
kj
::
arrayPtr
(
&
u
,
1
)));
}
}
const
size_t
maxNestingDepth
;
...
...
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