Although there are tons of links to convert json to object but here the requirement is bit different.
I have this xml -
{
  "structure": {
    "-type": "DivideByZeroException",
    "property": [
      {
        "-key": "Message",
        "#text": "Attempted to divide by zero."
      },
      { "-key": "Data" },
      { "-key": "InnerException" },
      {
        "-key": "TargetSite",
        "#text": "Void btnWriteError_Click(System.Object, System.Windows.RoutedEventArgs)"
      },
      {
        "-key": "StackTrace",
        "#text": "   at WpfApplication1.MainWindow.btnWriteError_Click(Object sender, RoutedEventArgs e) in c:\\Users\\Anil.Purswani\\Desktop\\WPF_Application\\WpfApplication1\\MainWindow.xaml.cs:line 169"
      },
      { "-key": "HelpLink" },
      {
        "-key": "Source",
        "#text": "WpfApplication1"
      },
      {
        "-key": "HResult",
        "#text": "-2147352558"
      }
    ]
  }
}
and would like to convert it into -
Class ModelError
{
   string Message;
   Exception InnerException;
   string TargetSite;
   string StackTrace;
   string HelpLink;
   string Source;
   string HResult;
}
So the final object should contain like this -
modelerrorobj.Message =  "Attempted to divide by zero."
modelerrorobj.Data = null;
modelerrorobj.InnerException = null;
modelerrorobj.Targetsite = "Void btnWriteError_Click(System.Object, System.Windows.RoutedEventArgs)";
modelerrorobj.StackTrace = "   at WpfApplication1.MainWindow.btnWriteError_Click(Object sender, RoutedEventArgs e) in c:\\Users\\Anil.Purswani\\Desktop\\WPF_Application\\WpfApplication1\\MainWindow.xaml.cs:line 169"
So basically, "-key" value i.e. "Message", "Data", "StackTrace" is the field in class ModelError and "#text" is the value of that corresponding field.
for e.g.
      {
        "-key": "Message",
        "#text": "Attempted to divide by zero."
      },
in above, "Message" is the field and "Attempted to divide by zero." is the value of that field.
Please note I have Json but how to convert it in ModelError?
 
    