Skip to content

JsonParser is unable to parse JSON messages serialized by Newtonsoft.Json or System.Text.Json due to mismatched property casing. #24759

@simon1749

Description

@simon1749

What version of protobuf and what language are you using?
Version: main/v3.6.0/v3.5.0 etc. (NOTE: please try updating to the latest version of protoc/runtime possible beforehand to attempt to resolve your problem)

Version: 3.32.1 from NuGet

Language: C++/Java/Python/C#/Ruby/PHP/Objective-C/Javascript

Language: C#

What operating system (Linux, Windows, ...) and version?
OS: Windows 11

What runtime / compiler are you using (e.g., python version or gcc version)
Runtime: .Net 9

What did you do?
Steps to reproduce the behavior:

  1. Create a protobuf message.
  2. Instantiate an object of the generated class and assign values to its properties.
  3. Use either Newtonsoft.Json or System.Text.Json to serialize the object to a JSON string.
  4. Use the Protobuf JsonParser to parse the JSON string from step 3.

What did you expect to see
The JsonParser should be able to parse the json string for it's a standard way of json deserialization.

What did you see instead?
Unknow filed exception was thrown.

While examining this related issue (#11987), I observed that CreateJsonFieldMap populates the map with both field.Name and field.JsonName. It seems reasonable that field.PropertyName should also be added after field.Name.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions