xmlnodeconverter can only convert json that begins with an object - Exception

Jun 14, 2012 at 11:04 PM

Hi team,

I am new to JSON and the web service I am consuming is returning JSON data like this. [please forgive me its too long]

[
{"portData":[
 {"Port or VE":"Eth12","VLAN ID":"252","VLAN(s) or Usage":"","NIC Team":"","VRRP":"","Speed/Duplex":"Auto","Connecting Device":"XXXXXXXX","Device Port":"Onboard1","Cable Type":"Ethernet Straight","IPV4 IP Address":"","IPV4 Subnet Mask":"","IPV4 Default Gateway":"","IPV4 Static Routes Network Addr.":"","IPV4 Static Routes Subnet Mask":"","IPV4 Static Route Next Hop":"","IPV6 IP Address":"","IPV6 Subnet Mask":"","IPV6 Default Gateway":"","IPV6 Static Routes Network Addr":"","IPV6 Static Routes Subnet Mask":"","IPV6 Static Route Next Hop":"","IP Protocol":"","Preferred IP":"","Rack No":"","Cable #1":"","Patch Panel ID ":"","Cable #2":"","Last Modified By":"XXXXXXXXXXXXXXX","Created Date":"5/7/2012 11:23:23 PM","Modifed Date":"5/7/2012 11:23:23 PM"},
 {"Port or VE":"Eth8","VLAN ID":"201","VLAN(s) or Usage":"","NIC Team":"","VRRP":"","Speed/Duplex":"Auto","Connecting Device":"XXXXXXXX","Device Port":"Onboard1","Cable Type":"Ethernet Straight","IPV4 IP Address":"","IPV4 Subnet Mask":"","IPV4 Default Gateway":"","IPV4 Static Routes Network Addr.":"","IPV4 Static Routes Subnet Mask":"","IPV4 Static Route Next Hop":"","IPV6 IP Address":"","IPV6 Subnet Mask":"","IPV6 Default Gateway":"","IPV6 Static Routes Network Addr":"","IPV6 Static Routes Subnet Mask":"","IPV6 Static Route Next Hop":"","IP Protocol":"","Preferred IP":"","Rack No":"","Cable #1":"","Patch Panel ID ":"","Cable #2":"","Last Modified By":"XXXXXXXXXXXXXXX","Created Date":"5/7/2012 10:22:08 PM","Modifed Date":"5/7/2012 10:22:08 PM"},
 {"Port or VE":"Eth11","VLAN ID":"201","VLAN(s) or Usage":"","NIC Team":"","VRRP":"","Speed/Duplex":"Auto","Connecting Device":"XXXXXXXX","Device Port":"Onboard1","Cable Type":"Ethernet Straight","IPV4 IP Address":"","IPV4 Subnet Mask":"","IPV4 Default Gateway":"","IPV4 Static Routes Network Addr.":"","IPV4 Static Routes Subnet Mask":"","IPV4 Static Route Next Hop":"","IPV6 IP Address":"","IPV6 Subnet Mask":"","IPV6 Default Gateway":"","IPV6 Static Routes Network Addr":"","IPV6 Static Routes Subnet Mask":"","IPV6 Static Route Next Hop":"","IP Protocol":"","Preferred IP":"","Rack No":"","Cable #1":"","Patch Panel ID ":"","Cable #2":"","Last Modified By":"XXXXXXXXXXXXXXX","Created Date":"5/7/2012 11:12:15 PM","Modifed Date":"5/7/2012 11:12:15 PM"},
 {"Port or VE":"Eth7","VLAN ID":"201","VLAN(s) or Usage":"","NIC Team":"","VRRP":"","Speed/Duplex":"Auto","Connecting Device":"XXXXXXXX","Device Port":"Onboard1","Cable Type":"Ethernet Straight","IPV4 IP Address":"","IPV4 Subnet Mask":"","IPV4 Default Gateway":"","IPV4 Static Routes Network Addr.":"","IPV4 Static Routes Subnet Mask":"","IPV4 Static Route Next Hop":"","IPV6 IP Address":"","IPV6 Subnet Mask":"","IPV6 Default Gateway":"","IPV6 Static Routes Network Addr":"","IPV6 Static Routes Subnet Mask":"","IPV6 Static Route Next Hop":"","IP Protocol":"","Preferred IP":"","Rack No":"","Cable #1":"","Patch Panel ID ":"","Cable #2":"","Last Modified By":"XXXXXXXXXXXXXXX","Created Date":"5/7/2012 10:06:51 PM","Modifed Date":"5/7/2012 10:06:51 PM"},
 {"Port or VE":"Eth10","VLAN ID":"201","VLAN(s) or Usage":"","NIC Team":"","VRRP":"","Speed/Duplex":"Auto","Connecting Device":"XXXXXXXX","Device Port":"Onboard1","Cable Type":"Ethernet Straight","IPV4 IP Address":"","IPV4 Subnet Mask":"","IPV4 Default Gateway":"","IPV4 Static Routes Network Addr.":"","IPV4 Static Routes Subnet Mask":"","IPV4 Static Route Next Hop":"","IPV6 IP Address":"","IPV6 Subnet Mask":"","IPV6 Default Gateway":"","IPV6 Static Routes Network Addr":"","IPV6 Static Routes Subnet Mask":"","IPV6 Static Route Next Hop":"","IP Protocol":"","Preferred IP":"","Rack No":"","Cable #1":"","Patch Panel ID ":"","Cable #2":"","Last Modified By":"XXXXXXXXXXXXXXX","Created Date":"5/7/2012 10:58:07 PM","Modifed Date":"5/7/2012 10:58:07 PM"},
 {"Port or VE":"Eth6","VLAN ID":"211","VLAN(s) or Usage":"","NIC Team":"","VRRP":"","Speed/Duplex":"Auto","Connecting Device":"XXXXXXXX","Device Port":"Onboard1","Cable Type":"Ethernet Straight","IPV4 IP Address":"","IPV4 Subnet Mask":"","IPV4 Default Gateway":"","IPV4 Static Routes Network Addr.":"","IPV4 Static Routes Subnet Mask":"","IPV4 Static Route Next Hop":"","IPV6 IP Address":"","IPV6 Subnet Mask":"","IPV6 Default Gateway":"","IPV6 Static Routes Network Addr":"","IPV6 Static Routes Subnet Mask":"","IPV6 Static Route Next Hop":"","IP Protocol":"","Preferred IP":"","Rack No":"","Cable #1":"","Patch Panel ID ":"","Cable #2":"","Last Modified By":"XXXXXXXXXXXXXXX","Created Date":"5/7/2012 9:44:06 PM","Modifed Date":"5/7/2012 9:44:06 PM"},
 {"Port or VE":"Eth4","VLAN ID":"204","VLAN(s) or Usage":"","NIC Team":"","VRRP":"","Speed/Duplex":"Auto","Connecting Device":"XXXXXXXX","Device Port":"Onboard1","Cable Type":"Ethernet Straight","IPV4 IP Address":"","IPV4 Subnet Mask":"","IPV4 Default Gateway":"","IPV4 Static Routes Network Addr.":"","IPV4 Static Routes Subnet Mask":"","IPV4 Static Route Next Hop":"","IPV6 IP Address":"","IPV6 Subnet Mask":"","IPV6 Default Gateway":"","IPV6 Static Routes Network Addr":"","IPV6 Static Routes Subnet Mask":"","IPV6 Static Route Next Hop":"","IP Protocol":"","Preferred IP":"","Rack No":"","Cable #1":"","Patch Panel ID ":"","Cable #2":"","Last Modified By":"XXXXXXXXXXXXXXX","Created Date":"5/7/2012 8:45:12 PM","Modifed Date":"5/7/2012 8:45:12 PM"},
 {"Port or VE":"10Gig Eth1","VLAN ID":"","VLAN(s) or Usage":"","NIC Team":"","VRRP":"","Speed/Duplex":"Auto","Connecting Device":"XXXXXXXX","Device Port":"Eth5","Cable Type":"Fiber Multimode","IPV4 IP Address":"","IPV4 Subnet Mask":"","IPV4 Default Gateway":"","IPV4 Static Routes Network Addr.":"","IPV4 Static Routes Subnet Mask":"","IPV4 Static Route Next Hop":"","IPV6 IP Address":"","IPV6 Subnet Mask":"","IPV6 Default Gateway":"","IPV6 Static Routes Network Addr":"","IPV6 Static Routes Subnet Mask":"","IPV6 Static Route Next Hop":"","IP Protocol":"","Preferred IP":"","Rack No":"","Cable #1":"","Patch Panel ID ":"","Cable #2":"","Last Modified By":"XXXXXXXXXXXXXXX","Created Date":"5/3/2012 4:19:02 AM","Modifed Date":"5/3/2012 4:19:02 AM"},
 {"Port or VE":"Eth2","VLAN ID":"204","VLAN(s) or Usage":"","NIC Team":"","VRRP":"","Speed/Duplex":"Auto","Connecting Device":"XXXXXXXX","Device Port":"Onboard1","Cable Type":"Ethernet Straight","IPV4 IP Address":"","IPV4 Subnet Mask":"","IPV4 Default Gateway":"","IPV4 Static Routes Network Addr.":"","IPV4 Static Routes Subnet Mask":"","IPV4 Static Route Next Hop":"","IPV6 IP Address":"","IPV6 Subnet Mask":"","IPV6 Default Gateway":"","IPV6 Static Routes Network Addr":"","IPV6 Static Routes Subnet Mask":"","IPV6 Static Route Next Hop":"","IP Protocol":"","Preferred IP":"","Rack No":"","Cable #1":"","Patch Panel ID ":"","Cable #2":"","Last Modified By":"XXXXXXXXXXXXXXX","Created Date":"5/7/2012 9:10:16 AM","Modifed Date":"5/7/2012 9:10:16 AM"},
 {"Port or VE":"Eth3","VLAN ID":"204","VLAN(s) or Usage":"","NIC Team":"","VRRP":"","Speed/Duplex":"Auto","Connecting Device":"XXXXXXXX","Device Port":"Onboard1","Cable Type":"Ethernet Straight","IPV4 IP Address":"","IPV4 Subnet Mask":"","IPV4 Default Gateway":"","IPV4 Static Routes Network Addr.":"","IPV4 Static Routes Subnet Mask":"","IPV4 Static Route Next Hop":"","IPV6 IP Address":"","IPV6 Subnet Mask":"","IPV6 Default Gateway":"","IPV6 Static Routes Network Addr":"","IPV6 Static Routes Subnet Mask":"","IPV6 Static Route Next Hop":"","IP Protocol":"","Preferred IP":"","Rack No":"","Cable #1":"","Patch Panel ID ":"","Cable #2":"","Last Modified By":"XXXXXXXXXXXXXXX","Created Date":"5/7/2012 9:23:49 AM","Modifed Date":"5/7/2012 9:23:49 AM"},
 {"Port or VE":"Eth9","VLAN ID":"201","VLAN(s) or Usage":"","NIC Team":"","VRRP":"","Speed/Duplex":"Auto","Connecting Device":"XXXXXXXX","Device Port":"Onboard1","Cable Type":"Ethernet Straight","IPV4 IP Address":"","IPV4 Subnet Mask":"","IPV4 Default Gateway":"","IPV4 Static Routes Network Addr.":"","IPV4 Static Routes Subnet Mask":"","IPV4 Static Route Next Hop":"","IPV6 IP Address":"","IPV6 Subnet Mask":"","IPV6 Default Gateway":"","IPV6 Static Routes Network Addr":"","IPV6 Static Routes Subnet Mask":"","IPV6 Static Route Next Hop":"","IP Protocol":"","Preferred IP":"","Rack No":"","Cable #1":"","Patch Panel ID ":"","Cable #2":"","Last Modified By":"XXXXXXXXXXXXXXX","Created Date":"5/7/2012 10:39:09 PM","Modifed Date":"5/7/2012 10:39:09 PM"},
 {"Port or VE":"Eth5","VLAN ID":"204","VLAN(s) or Usage":"","NIC Team":"","VRRP":"","Speed/Duplex":"Auto","Connecting Device":"XXXXXXXX","Device Port":"Onboard1","Cable Type":"Ethernet Straight","IPV4 IP Address":"","IPV4 Subnet Mask":"","IPV4 Default Gateway":"","IPV4 Static Routes Network Addr.":"","IPV4 Static Routes Subnet Mask":"","IPV4 Static Route Next Hop":"","IPV6 IP Address":"","IPV6 Subnet Mask":"","IPV6 Default Gateway":"","IPV6 Static Routes Network Addr":"","IPV6 Static Routes Subnet Mask":"","IPV6 Static Route Next Hop":"","IP Protocol":"","Preferred IP":"","Rack No":"","Cable #1":"","Patch Panel ID ":"","Cable #2":"","Last Modified By":"XXXXXXXXXXXXXXX","Created Date":"5/7/2012 9:28:14 PM","Modifed Date":"5/7/2012 9:28:14 PM"},
 {"Port or VE":"Eth1","VLAN ID":"204","VLAN(s) or Usage":"","NIC Team":"","VRRP":"","Speed/Duplex":"Auto","Connecting Device":"XXXXXXXX","Device Port":"Onboard1","Cable Type":"Ethernet Straight","IPV4 IP Address":"","IPV4 Subnet Mask":"","IPV4 Default Gateway":"","IPV4 Static Routes Network Addr.":"","IPV4 Static Routes Subnet Mask":"","IPV4 Static Route Next Hop":"","IPV6 IP Address":"","IPV6 Subnet Mask":"","IPV6 Default Gateway":"","IPV6 Static Routes Network Addr":"","IPV6 Static Routes Subnet Mask":"","IPV6 Static Route Next Hop":"","IP Protocol":"","Preferred IP":"","Rack No":"","Cable #1":"","Patch Panel ID ":"","Cable #2":"","Last Modified By":"XXXXXXXXXXXXXXX","Created Date":"5/7/2012 8:55:01 AM","Modifed Date":"5/7/2012 8:55:01 AM"}
 ],
"refIdData":
 {"REFID":"E1","Server Hostname":"XXXXXXXX","Virtual Asset Flag":"N","Device Type":"Switch","Device Manufacturer":"CISCO","Specific Model":"2248 Nexus Fabric Extender","Interworking Flag":"False","IPV4 Management IP":"","IPV6 Management IP":"","OOB":"","Compulert":"","Asset MGT/MON Type":"Advanced Managed","Equipment Function":"Customer","Server Farm":"","Asset Location":"","Community String":"monitor","Managing Center":"XXXXXXXX","Owner":"XXXXXXXX","Ownership":"","Serial No":"XXXXXXXX","Asset Tag":"","AENS Asset Tag":"","IP Protocol":"IPV4","Preferred IP":"IPV4","Last Modified By":"XXXXXXXX","Created Date":"4/27/2012 6:01:42 PM","Modified Date":"5/2/2012 4:55:37 AM"}
 }, ...

About 300+ records.

I feel there are already some errors in the string for e.g "Server Hostname" or "Port or VE" and I dont think I can create a class object of this. Apart form this when I just want to convert this to a XML using the following code.

string result = e.result;
XmlDocument xmlDocument = (XmlDocument)Newtonsoft.Json.JsonConvert.DeserializeXmlNode(result); 

I get the following error. "xmlnodeconverter can only convert json that begins with an object".

Please Advice,

Stephen