Generated output always contains 0, 3, 6, or 9 fractional digits, depending on required precision, followed by the suffix "s". Accepted are any fractional digits (also none) as long as they fit into nano-seconds precision and the suffix "s" is required.
Examples of this are "1.000340012s", and "1s".
Currently this library serializes Durations as an object, like so:
{ "seconds": 2, "nanos": 406273834 }
The specific issue I've run into here is that I am trying to use protojson in Go to parse a JSON protobuf generated from Rust. protojson expects the canonical encoding of durations (like "1s"), so my generated JSON is incompatible.
From the protobuf JSON Mapping specification, a Duration should be serialized as follows:
Examples of this are
"1.000340012s"
, and"1s"
.Currently this library serializes Durations as an object, like so:
The specific issue I've run into here is that I am trying to use
protojson
in Go to parse a JSON protobuf generated from Rust.protojson
expects the canonical encoding of durations (like"1s"
), so my generated JSON is incompatible.