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
6d765ffe
Commit
6d765ffe
authored
Sep 16, 2018
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix JSON field handlers not triggering on union members of annotated types.
parent
46ed8793
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletion
+23
-1
json-test.c++
c++/src/capnp/compat/json-test.c++
+15
-0
json-test.capnp
c++/src/capnp/compat/json-test.capnp
+7
-0
json.c++
c++/src/capnp/compat/json.c++
+1
-1
No files found.
c++/src/capnp/compat/json-test.c++
View file @
6d765ffe
...
...
@@ -975,6 +975,21 @@ KJ_TEST("rename fields") {
}
}
KJ_TEST
(
"base64 union encoded correctly"
)
{
// At one point field handlers were not correctly applied when the field was a member of a union
// in a type that was handled by annotation.
JsonCodec
json
;
json
.
handleByAnnotation
<
TestBase64Union
>
();
json
.
setPrettyPrint
(
true
);
MallocMessageBuilder
message
;
auto
root
=
message
.
getRoot
<
TestBase64Union
>
();
root
.
initFoo
(
5
);
KJ_EXPECT
(
json
.
encode
(
root
)
==
"{
\"
foo
\"
:
\"
AAAAAAA=
\"
}"
,
json
.
encode
(
root
));
}
}
// namespace
}
// namespace _ (private)
}
// namespace capnp
c++/src/capnp/compat/json-test.capnp
View file @
6d765ffe
...
...
@@ -114,3 +114,10 @@ enum TestJsonAnnotatedEnum {
baz @2 $Json.name("renamed-baz");
qux @3;
}
struct TestBase64Union {
union {
foo @0 :Data $Json.base64;
bar @1 :Text;
}
}
c++/src/capnp/compat/json.c++
View file @
6d765ffe
...
...
@@ -1255,7 +1255,7 @@ private:
// When we have an explicit union discriminant, we don't need to encode void fields.
}
else
{
flattenedFields
.
add
(
FlattenedField
{
prefix
,
info
.
name
,
which
->
getType
()
,
reader
.
get
(
*
which
)
});
prefix
,
info
.
name
,
*
which
,
reader
.
get
(
*
which
)
});
}
}
}
...
...
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