Skip to content

Commit ae1710b

Browse files
committed
Configuration - add docs
1 parent 5cea4c9 commit ae1710b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,23 @@ or deserialize `Google.Protobuf` objects:
4141
var deserialized = JsonSerializer.Deserialize<SimpleMessage>(payload, jsonSerializerOptions);
4242
```
4343

44+
## Configuration
45+
The library offers several configuration options to fine-tune protobuf serialization. You can modify the default settings using a delegate passed to the AddProtobufSupport method. The available options are described below:
46+
47+
### UseProtobufJsonNames
48+
This option defines how property names should be resolved for protobuf contracts. When set to `true`, the `PropertyNamingPolicy` will be ignored, and property names will be derived from the protobuf contract. The default value is `false`.
49+
50+
### TreatDurationAsTimeSpan
51+
This option controls how `Google.Protobuf.WellKnownTypes.Duration` fields are handled. When set to true, `Google.Protobuf.WellKnownTypes.Duration` properties will be converted to `TimeSpan` before serialization and will be expected in the same format as `TimeSpan` during deserialization. The default value is `true`.
52+
53+
### TreatTimestampAsDateTime
54+
This option controls how `Google.Protobuf.WellKnownTypes.Timestamp` fields are handled. When set to true, `Google.Protobuf.WellKnownTypes.Timestamp` properties will be converted to DateTime before serialization and will be expected in the same format as `DateTime` during deserialization. The default value is `true`.`
55+
56+
### UseStringProtoEnumValueNames
57+
By setting`UseStringProtoEnumValueNames` to `true`, the library will serialize enum values using the names specified in the .proto file and expect the same format during deserialization. The default value is `false`.
58+
59+
By customizing these options, you can control how the library handles various aspects of protobuf serialization and deserialization, ensuring the JSON output is consistent with your requirements.
60+
4461
## Performance
4562

4663
``` ini

0 commit comments

Comments
 (0)