Skip to content

Deserializing feed: missing optional fields return 0 value in node.js #53

@nselikoff

Description

@nselikoff

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.

const feed = realtime.transit_realtime.FeedMessage.decode(protobuf);
feed.entity.forEach((entity) => {
  if (entity.vehicle) {
    const speed = entity.vehicle.position.speed; // speed is 0
  }
});

This may be similar to #52

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions