userver
C++ Async Framework
Loading...
Searching...
No Matches
convert_options.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/protobuf/json/convert_options.hpp
4
/// @brief Protobuf messages to/from JSON `ValueBuilder`/`Value` conversion options.
5
6
USERVER_NAMESPACE_BEGIN
7
8
namespace
protobuf::json {
9
10
/// @brief Options which affect how JSON `Value` is converted to a protobuf message.
11
struct
ParseOptions
{
12
/// @brief Ignore unknown JSON fields and enum value names.
13
/// If not set, conversion of a JSON object containing unknown field (i.e. field that is not mapped to any protobuf
14
/// message field) or unknown enum value name will fail.
15
bool
ignore_unknown_fields
=
false
;
16
};
17
18
/// @brief Options which affect how protobuf message is converted to a JSON `ValueBuilder`/`Value`.
19
struct
PrintOptions
{
20
/// @brief Always output protobuf message fields that do not have explicit presence.
21
/// This fields are:
22
/// * implicit presence fields set to default value
23
/// * empty repeated/map fields
24
bool
always_print_fields_with_no_presence
=
false
;
25
26
/// @brief Output enum values as integers, not as their string names.
27
bool
always_print_enums_as_ints
=
false
;
28
29
/// @brief Output field names exactly how specified in the proto file (usually *lower_snake_case*).
30
/// By default, protobuf message field names are converted to `lowerCamelCase` format.
31
/// @note If protobuf message field has `json_name` option attached, then it's value is used for the JSON key
32
/// name and this option does not have effect.
33
/// @warning According to protobuf rules this option **does not have effect** on the field names specified in the
34
/// `google.protobuf.FieldMask` paths during conversion. I.e., field names inside `FieldMask` are always
35
/// encoded in `lowerCamelCase` no matter whether `preserve_proto_field_names` is on or off. Moreover,
36
/// `json_name` option is also not taken into account for `FieldMask` paths.
37
bool
preserve_proto_field_names
=
false
;
38
};
39
40
}
// namespace protobuf::json
41
42
USERVER_NAMESPACE_END
protobuf
include
userver
protobuf
json
convert_options.hpp
Generated on Tue Jun 30 2026 13:11:13 for userver by
Doxygen
1.13.2