mapbox / pbf

A low-level, lightweight protocol buffers implementation in JavaScript.
BSD 3-Clause "New" or "Revised" License
801 stars 107 forks source link

Empty string decoded as true as map value #116

Closed yunyu closed 4 years ago

yunyu commented 4 years ago

Given the following proto:

message MyMessage {
  map<string, string> myDict = 1;
}

Running

const pbf = new Pbf();
MyMessage.write({foo: "", bar: "hi"}, pbf);
console.log(MyMessage.read(new Pbf(pbf.finish()));

Results in { foo: true, bar: "hi" } instead of the expected {foo: "", bar: "hi"}.

yunyu commented 4 years ago

This was my fault - I had 2 fields with the same number assigned.