We have a long living app that uses some feed that used to be xml, but was converted to json... Of course we were "to lazy" to change parser from reading XmlDocument to read JObject or other so we used "DeserializeXmlNode" to convert from json txt to XmlDocument. All was fine for a long long time... until we updated from Newtonsoft.Json versions 4.5 and 6.0 to version 12.0.x and suddenly we started to have some problems...
let's say json looks like this:
{"version":"2.0","result":[{"mainobid":"123","typeId":"2","subobjects":{"1":{"data":"data"},"2":{"data":"data"}}}]}
what we used to get was xml having
<1><data>data</data></1><2><data>data</data></2>
tags
now... instead of <1> tag we get something like <x0031> instead of 10 there's _x0031_0 instead of 45 there's 0x0034_5 and instead of 100 _x0031_00
Can I turn that off somehow? or am I forced now to change parsing to decode that sick x003.... thing?
INB4 1: I realize that having 1: and <1> is not the thing that anyone sane wishes to have, but i can't change that, it's external feed
INB4 2: I know we should change parsing from xml to json, but as above - some lazines and re-using old code that was working 100% good.
EDIT:
private static void TestOldNewton()
{
var jsonstr = "{\"version\":\"2.0\",\"result\":[{\"mainobid\":\"123\",\"typeId\":\"2\",\"subobjects\":{\"1\":{\"data\":\"data\"},\"2\":{\"data\":\"data\"}}}]}";
var doc = Newtonsoft.Json.JsonConvert.DeserializeXmlNode(jsonstr, "data");
Console.WriteLine(doc.OuterXml);
Console.ReadKey();
}
using packages.config like:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="6.0.1" targetFramework="net48" />
</packages>
and receiving output:
<data><version>2.0</version><result><mainobid>123</mainobid><typeId>2</typeId><subobjects><1><data>data</data></1><2><data>data</data></2></subobjects></result></data>
freshly compiled and run on new, testing project.