Is it possible to return a dynamic object from a json deserialization using json.net? I would like to do something like this:
dynamic jsonResponse = JsonConvert.Deserialize(json);
Console.WriteLine(jsonResponse.message);
|
latest json.net version allow do this:
output:
Documentation here: LINQ to JSON with Json.NET |
|||||
|
As of Json.NET 4.0 Release 1, there is native dynamic support:
And, of course, the best way to get the current version is via NuGet. |
||||
|
I know this is old post but JsonConvert actually has a different method so it would be
|
|||||||||
|
You need to have some sort of type to deserialize to. You could do something along the lines of:
Note: My answer was based on a solution for .NET 4.0's build in JSON serializer. Here is a link to deserialize to anonymous types is here: |
||||
|
Yes you can do it using the JsonConvert.Deserialize. To do that, just simple do:
|
|||
|