XML : vb.net generation of dynamic class from XML to JSON

What I am trying to achieve is convert XML to a JSON object. Currently I am doing it like this:

  Public Class Person      Public Property Name As String      ' snip  End Class    Dim doc As XmlDocument  doc.LoadXml(arg_strXml)  Dim jsonValue As String = JsonConvert.SerializeXmlNode(doc)  Dim jsonObject = JsonConvert.DeserializeObject(Of Person)(jsonValue)    Dim firstName As String = jsonObject.Name    

However the issue is the retrieved XML, and thus the deserialized JSON object has different fields/properties/elements depending on the correct function. It would be a nightmare to have a class for each possible XML.

Is there a way round not having to create a specific class (Person in this case) for each deserialize?

No comments:

Post a Comment