Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
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
protobuf
Commits
3cae8e44
Commit
3cae8e44
authored
Jan 28, 2019
by
Paul Yang
Committed by
Bo Yang
Jan 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Default values should also be serialized for json map key/value (#5643)
parent
a73b4359
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
4 deletions
+15
-4
failure_list_php_c.txt
conformance/failure_list_php_c.txt
+0
-1
encode_decode.c
php/ext/google/protobuf/encode_decode.c
+2
-3
encode_decode_test.php
php/tests/encode_decode_test.php
+13
-0
No files found.
conformance/failure_list_php_c.txt
View file @
3cae8e44
...
...
@@ -23,7 +23,6 @@ Required.DurationProtoInputTooLarge.JsonOutput
Required.DurationProtoInputTooSmall.JsonOutput
Required.TimestampProtoInputTooLarge.JsonOutput
Required.TimestampProtoInputTooSmall.JsonOutput
Required.Proto3.JsonInput.BoolMapField.JsonOutput
Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
Required.Proto3.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput
Required.Proto3.JsonInput.DoubleFieldMinPositiveValue.JsonOutput
...
...
php/ext/google/protobuf/encode_decode.c
View file @
3cae8e44
...
...
@@ -1163,7 +1163,7 @@ static void put_optional_value(const void* memory, int len,
#define T(upbtypeconst, upbtype, ctype, default_value) \
case upbtypeconst: { \
ctype value = DEREF(memory, 0, ctype); \
if (
value != default_value) {
\
if (
is_json || value != default_value) {
\
upb_selector_t sel = getsel(f, upb_handlers_getprimitivehandlertype(f)); \
upb_sink_put##upbtype(sink, sel, value); \
} \
...
...
@@ -1181,8 +1181,7 @@ static void put_optional_value(const void* memory, int len,
#undef T
case
UPB_TYPE_STRING
:
case
UPB_TYPE_BYTES
:
putrawstr
(
memory
,
len
,
f
,
sink
,
is_json
&&
is_wrapper_msg
(
upb_fielddef_containingtype
(
f
)));
putrawstr
(
memory
,
len
,
f
,
sink
,
is_json
);
break
;
case
UPB_TYPE_MESSAGE
:
{
#if PHP_MAJOR_VERSION < 7
...
...
php/tests/encode_decode_test.php
View file @
3cae8e44
...
...
@@ -1135,4 +1135,17 @@ class EncodeDecodeTest extends TestBase
$this
->
assertEquals
(
""
,
$m
->
serializeToString
());
}
public
function
testJsonDecodeMapWithDefaultValueKey
()
{
$m
=
new
TestMessage
();
$m
->
getMapInt32Int32
()[
0
]
=
0
;
$this
->
assertSame
(
"
{
\"mapInt32Int32\":{\"0\":0}
}
"
,
$m
->
serializeToJsonString
());
$m
=
new
TestMessage
();
$m
->
getMapStringString
()[
""
]
=
""
;
$this
->
assertSame
(
"
{
\"mapStringString\":{\"\":\"\"}
}
"
,
$m
->
serializeToJsonString
());
}
}
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