chobie / php-protocolbuffers

PECL ProtocolBuffers
pecl.php.net/package/protocolbuffers
Other
128 stars 38 forks source link

fixbug: when call json_encode or toArray, fields of BYTES are encoded to zero. #51

Open bryceliu opened 9 years ago

bryceliu commented 9 years ago

When call json_encode or toArray, fields of BYTES are encoded to zero.


Message definition:

message Person                 
{
    required bytes name = 1;   
    required uint32 age = 2;   
}

PHP test code:

require 'person.proto.php';
$person = new Person();
$person->setName('bryce');
$person->setAge(18);
var_dump($person->toArray());
var_dump(json_encode($person));

PHP output:

array(2) {
  ["name"]=>
  int(0)
  ["age"]=>
  int(18)
}
string(19) "{"name":0,"age":18}"