示例#1
0
        public void ConvertToJson_OnBasicXml_ShouldConvertToJson()
        {
            const string xml = @"<main><el1 att1=""value""/><el2><el3 att3=""nested value""/></el2></main>";
            var          act = XmlConverter.ConvertToJson(XDocument.Parse(xml));

            act.Should().Be("{\"main\":{\"el1\":{\"att1\":\"value\"},\"el2\":{\"el3\":{\"att3\":\"nested value\"}}}}");
        }
示例#2
0
    public string JsonToXml(string xml)
    {
        var    convert = new XmlConverter();
        string json;

        try
        {
            json = convert.ConvertToJson(xml);
        }
        catch (Exception exception) // TODO: Specialiser les exceptions
        {
            Console.Error.WriteLine(exception);
            return("Bad Xml format");
        }

        return(json);
    }
 public BsonDocument ConvertToJsonToBson()
 {
     return(BsonDocument.Parse(XmlConverter.ConvertToJson(_processItem)));
 }