Skip to content

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

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

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

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

Successfully merging this pull request may close these issues.

2 participants