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 |
||||
|
I know this is old post but JsonConvert actually has a different method so it would be
|
|||
|
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. |
|||
|
You need to have some sort of type to deserialize to. You could do something along the lines of:
Edit: epitka, there was no need to edit my answer. My answer was based on a solution for .NET 4.0's build in JSON serializer. Edit2: since epitka is having a cry and down-voted without reason, link to deserialize to anonymous types is here: |
|||||||||||
|