userver: protobuf::json::PrintOptions Struct Reference
Loading...
Searching...
No Matches
protobuf::json::PrintOptions Struct Reference

#include </data/code/userver/libraries/protobuf/include/userver/protobuf/json/convert_options.hpp>

Detailed Description

Options which affect how protobuf message is converted to a JSON ValueBuilder/Value.

Definition at line 28 of file convert_options.hpp.

Public Attributes

bool always_print_fields_with_no_presence = false
 Always output protobuf message fields that do not have explicit presence. This fields are:
bool always_print_enums_as_ints = false
 Output enum values as integers, not as their string names.
bool preserve_proto_field_names = false
 Output field names exactly how specified in the proto file (usually lower_snake_case). By default, protobuf message field names are converted to lowerCamelCase format.
bool nonportable_raw_any = false
 Serialize google.protobuf.Any as a raw {"typeUrl": "...", "value": "<base64>"} JSON object without looking up the payload descriptor in the descriptor pool. When set, value is base64-encoded protobuf wire bytes of the payload. If preserve_proto_field_names is true, type_url is used instead of typeUrl.

Member Data Documentation

◆ always_print_enums_as_ints

bool protobuf::json::PrintOptions::always_print_enums_as_ints = false

Output enum values as integers, not as their string names.

Definition at line 36 of file convert_options.hpp.

◆ always_print_fields_with_no_presence

bool protobuf::json::PrintOptions::always_print_fields_with_no_presence = false

Always output protobuf message fields that do not have explicit presence. This fields are:

  • implicit presence fields set to default value
  • empty repeated/map fields

Definition at line 33 of file convert_options.hpp.

◆ nonportable_raw_any

bool protobuf::json::PrintOptions::nonportable_raw_any = false

Serialize google.protobuf.Any as a raw {"typeUrl": "...", "value": "<base64>"} JSON object without looking up the payload descriptor in the descriptor pool. When set, value is base64-encoded protobuf wire bytes of the payload. If preserve_proto_field_names is true, type_url is used instead of typeUrl.

Warning
This is a userver-only extension that is not supported in other frameworks. Only userver can correctly parse this format.

Definition at line 55 of file convert_options.hpp.

◆ preserve_proto_field_names

bool protobuf::json::PrintOptions::preserve_proto_field_names = false

Output field names exactly how specified in the proto file (usually lower_snake_case). By default, protobuf message field names are converted to lowerCamelCase format.

Note
If protobuf message field has json_name option attached, then it's value is used for the JSON key name and this option does not have effect.
Warning
According to protobuf rules this option does not have effect on the field names specified in the google.protobuf.FieldMask paths during conversion. I.e., field names inside FieldMask are always encoded in lowerCamelCase no matter whether preserve_proto_field_names is on or off. Moreover, json_name option is also not taken into account for FieldMask paths.

Definition at line 46 of file convert_options.hpp.


The documentation for this struct was generated from the following file: