-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deserializing feed: missing optional fields return 0 value in node.js #53
Comments
@nselikoff Thanks for the report! In Java bindings there is a |
@barbeau good question - just looked and there is not a similar method. However, I found a workaround using const feed = realtime.transit_realtime.FeedMessage.decode(protobuf);
feed.entity.forEach((entity) => {
if (entity.vehicle) {
// using `toObject` only adds properties that exist in the protobuf
const position = realtime.transit_realtime.Position.toObject(entity.vehicle.position);
// so speed will be undefined if not included in the protobuf
const speed = position.speed;
// maybe you want it null
// const speed = position.speed || null;
}
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Given a feed that does NOT have an optional field (e.g. vehicle speed), the value returned when getting this value is
0
. So there's no way to differentiate "not included" from an actual value of zero.This may be similar to #52
The text was updated successfully, but these errors were encountered: