Skip to content

Commit b293a71

Browse files
CopilotHavret
andcommitted
Update README with PropertyNamingSource documentation
Co-authored-by: Havret <9103861+Havret@users.noreply.github.com>
1 parent 8614e6b commit b293a71

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,26 @@ var deserialized = JsonSerializer.Deserialize<SimpleMessage>(payload, jsonSerial
4444
## Configuration
4545
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:
4646

47-
### UseProtobufJsonNames
47+
### PropertyNamingSource
48+
This option specifies the source for property names in JSON serialization. The default value is `PropertyNamingSource.Default`.
49+
50+
Available values:
51+
- `PropertyNamingSource.Default`: Use the default `PropertyNamingPolicy` from `JsonSerializerOptions`.
52+
- `PropertyNamingSource.ProtobufJsonName`: Use the JsonName from the protobuf contract. This is usually the lower-camel-cased form of the field name, but can be overridden using the `json_name` option in the .proto file.
53+
- `PropertyNamingSource.ProtobufFieldName`: Use the original field name as defined in the .proto file (e.g., "double_property" instead of "doubleProperty").
54+
55+
Example:
56+
```csharp
57+
var jsonSerializerOptions = new JsonSerializerOptions();
58+
jsonSerializerOptions.AddProtobufSupport(options =>
59+
{
60+
options.PropertyNamingSource = PropertyNamingSource.ProtobufFieldName;
61+
});
62+
```
63+
64+
### UseProtobufJsonNames (Obsolete)
65+
**Note:** This property is obsolete and will be removed in a future version. Use `PropertyNamingSource` instead.
66+
4867
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`.
4968

5069
### TreatDurationAsTimeSpan

0 commit comments

Comments
 (0)