S
S
sergeevpetro2016-10-06 10:06:32
C++ / C#
sergeevpetro, 2016-10-06 10:06:32

How to convert large JSON file to XML?

Hello!
In general, the current implementation is as follows:

string file = File.ReadAllText("file.json");
XmlDocument doc = JsonConvert.DeserializeXmlNode("{\"dialog\":" + file + "}", "root");
file = doc.InnerXml.Replace("<root>", "<root><dialogs>");
doc = null;
file = file.Replace("</root>", "</dialogs></root>");
...
File.WriteAllText("output.xml", file);

instead of an ellipsis there are a few more Replaces. The JSON file weighs 400-700 MB and with this implementation OutOfMemoryException crashes at the first Replace.
How to be? What solutions can be given to this situation?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Eremin, 2016-10-06
@EreminD

  1. We take www.newtonsoft.com/json
  2. We do it like this
  3. Ready. You are wonderful!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question