C
C#16mo ago
Messiah

❔ OSS/Examples for JSON Deserialization?

I'm working on a mid-sized application that does a lot of json deserialization from third party API responses. Does anyone knows where I could find some OSS projects that use json document/node that I could use as reference for advanced json processing?
7 Replies
Angius
Angius16mo ago
What's wrong with System.Text.Json? It has a JsonDocument class or whatever it's called that lets you handle bullshit JSON without deserializing it Would you look at that, it's the exact name actually lol https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsondocument?view=net-7.0
Messiah
MessiahOP16mo ago
I'm using system.text.json, I'm looking for some projects that integrate json deserialization with more complex operations like case sensitity, checking if the value exists in the json some fancy use cases for TryGetJsonProperty()
Angius
Angius16mo ago
Those aren't really complex tbh. For case sensitivity just set the options of the serializer, and for checking the value... make it nullable in the model you deserialize to. Or, indeed, use a JsonDocument and do all the weird shit you need with it .TryGetJsonProperty() is useful when the JSON you get is utter shit and doesn't conform to any schema So you can check if the property exists, and get it only if it does As far as any specific projects that deal with bullshit JSON go, nothing comes to mind Usually you just ensure the JSON you deal with is sane
Messiah
MessiahOP16mo ago
the serializer options don't work with json elements, no? yup, my use case.
Angius
Angius16mo ago
True, true I guess your best bet would be enumerating all properties and doing comparisons that ignore case that way
Messiah
MessiahOP16mo ago
awesome, I'll do that. Thanks
Accord
Accord16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?