Deserialize JSON to dynamic object without Newtonsoft.Json
Hi, is there a way to deserialize json object to
dynamic
in .net? ideally from HttpContent.
I don't want to use additional dependency, but i can't find vanilla solution.
Thanks for help!24 Replies
Why do you want a dynamic object?
Also
System.Text.Json
exists and is completely built-in.i don't want to create a lot of classes for processing api response
ill check it, thanks
you dont need to, you can deserialize to an object (and probably to a dynamic) and use
.GetProperty
Well you really should
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
You can use special paste or any online JSON to C# converter
Don't use dynamic. Period.
this solution sounds cool
ill try that
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I dont recommend it. Like, I seriously dont recommend it
hmm
okay
ill create that classes
Thanks for help guys!
wow, this is very cool, thanks
$jsongen
Instantly parse JSON in any language | quicktype
Whether you're using C#, Swift, TypeScript, Go, C++ or other languages, quicktype generates models and helper code for quickly and safely reading JSON in your apps. Customize online with advanced options, or download a command-line tool.
Convert JSON to C# Classes Online - Json2CSharp Toolkit
Convert any JSON object to C# classes online. Json2CSharp is a free toolkit that will help you generate C# classes on the fly.
are those sites defaulting to system.text.json yet?
nope
they are good enough for creating the classes, but any helper methods/suggestions in comments will lead you down the path of newtonsoft.json. There's also a few difference to keep in mind, for example, system.text.json is much more strict -- it won't ignore case differences between the json and the c# class by default, for example.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
asp.net core does
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
i'm pretty sure it supports it with s.t.j
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
JsonPatch in ASP.NET Core web API
Learn how to handle JSON Patch requests in an ASP.NET Core web API.
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
so yeah, it is based on newtonsoft still
reading more of that page, yeah, it's still newtonsoft, even if you're using s.t.json normally, this doc tells you how to get it working with newtonsoft
LitJson
Although I think Newtonsoft still rocks
I had the same issue few months ago
Haha