c# - How can i convert XML to json (without using Json.NET) -


for past 2 hours have tried parse xml json. in example project did did that:

string  xmlstring = xdocument.load("g00011071.xml").tostring(); xmldocument xml = new xmldocument(); xml.loadxml(xmlstring);  var json = newtonsoft.json.jsonconvert.serializeobject(xml); 

and worked fine..

when tried integrate in project need use there got error:

an exception of type 'system.io.fileloadexception' occurred in xmloutput.dll not handled in user code. additional information: not load file or assembly 'newtonsoft.json, version=8.0.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed' or 1 of dependencies. located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040)

i tried solve it, nothing helped - decided not use json.net , looked alternatives, found post:

but xml structure much more complex 1 used there..

how can achieve same result 1 json.net produced?

you seem have version mismatch between assembly referenced , assembly available. if have multiple projects make sure of them using same version of json.net. json.net tool job , writing code available proven library (and test , maintain it) not worth it.


Comments