Unverified Commit 6b3024f6 authored by Paul Yang's avatar Paul Yang Committed by GitHub

Accept string for int64 wrappers (#6491)

parent ee4f2492
......@@ -58,8 +58,6 @@ Required.Proto3.JsonInput.FloatFieldInfinity.JsonOutput
Required.Proto3.JsonInput.FloatFieldNan.JsonOutput
Required.Proto3.JsonInput.FloatFieldNegativeInfinity.JsonOutput
Required.Proto3.JsonInput.OneofFieldDuplicate
Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
Required.Proto3.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
Required.Proto3.JsonInput.RejectTopLevelNull
Required.Proto3.JsonInput.StringFieldSurrogatePair.JsonOutput
Required.Proto3.JsonInput.StringFieldSurrogatePair.ProtobufOutput
......
......@@ -9964,7 +9964,8 @@ static bool start_any_stringval(upb_json_parser *p) {
static bool start_stringval(upb_json_parser *p) {
if (is_top_level(p)) {
if (is_string_wrapper_object(p)) {
if (is_string_wrapper_object(p) ||
is_number_wrapper_object(p)) {
start_wrapper_object(p);
} else if (is_wellknown_msg(p, UPB_WELLKNOWN_FIELDMASK)) {
start_fieldmask_object(p);
......@@ -9977,7 +9978,8 @@ static bool start_stringval(upb_json_parser *p) {
} else {
return false;
}
} else if (does_string_wrapper_start(p)) {
} else if (does_string_wrapper_start(p) ||
does_number_wrapper_start(p)) {
if (!start_subobject(p)) {
return false;
}
......@@ -10183,7 +10185,8 @@ static bool end_stringval(upb_json_parser *p) {
return false;
}
if (does_string_wrapper_end(p)) {
if (does_string_wrapper_end(p) ||
does_number_wrapper_end(p)) {
end_wrapper_object(p);
if (!is_top_level(p)) {
end_subobject(p);
......
......@@ -118,12 +118,19 @@ class EncodeDecodeTest extends TestBase
$this->assertEquals(1, $m->getValue());
}
# public function testEncodeTopLevelInt64Value()
# {
# $m = new Int64Value();
# $m->setValue(1);
# $this->assertSame("\"1\"", $m->serializeToJsonString());
# }
public function testDecodeTopLevelInt64ValueAsString()
{
$m = new Int64Value();
$m->mergeFromJsonString("\"1\"");
$this->assertEquals(1, $m->getValue());
}
public function testEncodeTopLevelInt64Value()
{
$m = new Int64Value();
$m->setValue(1);
$this->assertSame("\"1\"", $m->serializeToJsonString());
}
public function testDecodeTopLevelUInt64Value()
{
......@@ -132,12 +139,19 @@ class EncodeDecodeTest extends TestBase
$this->assertEquals(1, $m->getValue());
}
# public function testEncodeTopLevelUInt64Value()
# {
# $m = new UInt64Value();
# $m->setValue(1);
# $this->assertSame("\"1\"", $m->serializeToJsonString());
# }
public function testDecodeTopLevelUInt64ValueAsString()
{
$m = new UInt64Value();
$m->mergeFromJsonString("\"1\"");
$this->assertEquals(1, $m->getValue());
}
public function testEncodeTopLevelUInt64Value()
{
$m = new UInt64Value();
$m->setValue(1);
$this->assertSame("\"1\"", $m->serializeToJsonString());
}
public function testDecodeTopLevelStringValue()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment