I have JSON which looks like:
{
"name": "foo",
"settings": {
"setting1": true,
"setting2": 1
}
}
I know how to use json2csharp.com to create the C# classes to deserialize this. They looks like:
public class Settings
{
public bool settings1 { get; set; }
public int settings2 { get; set; }
}
public class RootObject
{
public string name { get; set; }
public Settings settings { get; set; }
}
but what I want is to simply deserialize it into
public class RootObject
{
public string name { get; set; }
public string settings { get; set; }
}
i.e., all of the "setting" JSON just needs to be saved as a string--the structure of that JSON is not consistent. How can that be done? Thanks!
codevar rawObj = JsonConvert.DeserializeObject<dynamic>(json); var uniq = rawObj.name; var settings = rawObj.settings;codethanks for the ideadynamicin that answer, but nothing is stopping you from making it into aDictionary<string, string>or something similar. If it helped at all, I'll call it a win. Good luck!