Created
September 26, 2016 19:17
-
-
Save deepumi/0ce1fd6e018d170c6b64b2c313cbe242 to your computer and use it in GitHub Desktop.
Convert json string to XML node from reflection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Runtime.Serialization.Json; | |
using System.Text; | |
using System.Xml.Linq; | |
internal static string JsonToXmlResponse(this Type type) | |
{ | |
if (type == null) return string.Empty; | |
var json = new ObjectGenerator().GenerateObject(type).Serialize(); | |
var xml = XDocument.Load(JsonReaderWriterFactory.CreateJsonReader(Encoding.ASCII.GetBytes(json), new XmlDictionaryReaderQuotas())); | |
return xml.ToString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment