How to serialize/deserialize with STJ #6034
Replies: 1 comment 2 replies
-
Hi @brandonh-msft Models generated by kiota leverage auto-serialization (they describe in a library and format agnostic way how to serialize/deserialize themselves). For that reason, the STJ annotations are not emitted, and most models "won't work properly" using STJ's serialization methods directly. Kiota libraries provide helpers to handle serialization and deserialization outside of the context of communicating with the API. see this method and associated The challenge in your context is that the model is encapsulated with another type not generated by kiota. I'd suggest you create another model for local JSON serialization and implement conversion between the two instead. Let us know if you have any additional comments or questions. |
Beta Was this translation helpful? Give feedback.
-
I have objects in my application which are "composed" of a JSON object that contains an API object. Said another way, I handle serialize/deserialize of objects that have "extra" data, then a property
myObj
which is an API object referencing those created by Kiota.The problem I'm having is that I cannot
JsonSerializer.Deserialize<MyObject>()
and have it properly deserialize the kiotaObject, because Kiota doesn't decorate its generated properties withJsonPropertyName
but instead uses a mapping dictionary.What's the best approach here? Are there any plans to pivot, at least for .NET, to fully using STJ?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions