Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions protobuf-json-mapping/src/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,19 @@ impl PrintableToJson for f64 {
impl PrintableToJson for u64 {
fn print_to_json(&self, w: &mut Printer) -> PrintResult<()> {
// 64-bit integers are quoted by default
if w.print_options.unquoted_64bit_integers {
return Ok(write!(w.buf, "{}", self)?);
}
Ok(write!(w.buf, "\"{}\"", self)?)
}
}

impl PrintableToJson for i64 {
fn print_to_json(&self, w: &mut Printer) -> PrintResult<()> {
// 64-bit integers are quoted by default
if w.print_options.unquoted_64bit_integers {
return Ok(write!(w.buf, "{}", self)?);
}
Ok(write!(w.buf, "\"{}\"", self)?)
}
}
Expand Down Expand Up @@ -563,6 +569,8 @@ pub struct PrintOptions {
pub proto_field_name: bool,
/// Output field default values.
pub always_output_default_values: bool,
/// Do not quote 64-bit integers.
pub unquoted_64bit_integers: bool,
/// Prevent initializing `PrintOptions` enumerating all field.
pub _future_options: (),
}
Expand Down
Loading