Skip to main content

message_to_json

Function message_to_json 

Source
pub(crate) fn message_to_json<M: ReflectMessage>(msg: &M) -> String
Expand description

Serialises a message in the fixture JSON convention: the C++ MessageToJsonString with add_whitespace, preserve_proto_field_names and always-print-fields-without-presence.

One space of indent per level, fields in field-number order, every field without presence printed even at its default, unset messages and unset optional/oneof fields omitted, 64-bit integers as strings, enums by name, floats as the C++ library writes them. Ends with a newline, as the C++ output does.