我将XML转换为JSON,如下所示:
Dim doc As XmlDocument
doc.LoadXml(arg_strXml)
Dim jsonObject As String = JsonConvert.SerializeXmlNode(doc)
现在我希望能够进入jsonObject来获取值,就像这样
Dim mode As String = jsobObject.mode
或更高级的例子
Dim usersFirstName As String = jsonObject.people[1].firstname
我是否需要创建一个代表XML结构的类,或者我可以采用另一种方式,即使我失去了intellisense,也是如此
Dim mode As String = jsonObject["mode"]
答案 0 :(得分:0)
好像你第一次转换是不必要的,
您可以使用LINQ to XML和vb.net
XML Literals
Dim xmlString as String = "
<someobject>
<property1>Value 1</property1>
<property2>1001</property2>
</someobject>"
Dim xmlObject As XElement = XElement.Parse(xmlString)
Dim value1 As String = xmlObject.<property1>.First().Value
Dim value2 As String = xmlObject.<property2>.First().Value