Skip to content

Conversation

bryceliu
Copy link

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}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants