Protobuf: PHP: json_name honored in pure-php impl, ignored in C extension

Created on 29 Nov 2017  路  2Comments  路  Source: protocolbuffers/protobuf

When using the json_name option to control the name of serialized attributes, the pure-PHP implementation of protobuf works as expected. However the C extension ignores the option completely.

// test.prot

syntax="proto3";

message Foo {
    int32 foo = 1 [json_name="bar"];
}
<?php

// test.php

require "vendor/autoload.php";

$foo = new Foo();
$foo->setFoo(42);

echo $foo->serializeToJsonString(), "\n";
$ protoc --php_out=. test.proto
$ php test.php
{"bar":42} # ok
$ php -dextension=protobuf.so test.php
{"foo":42} # not ok with extension
P2 bug php

All 2 comments

This is a known issue in c extension. Currently, we haven't fixed all conformance test for c extension. Will do it gradually.

whitch version will support?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

laszloagardi picture laszloagardi  路  40Comments

cl51287 picture cl51287  路  29Comments

xfxyjwf picture xfxyjwf  路  35Comments

Interfere picture Interfere  路  30Comments

little-dude picture little-dude  路  88Comments