Created
February 3, 2009 08:21
-
-
Save atifaziz/57409 to your computer and use it in GitHub Desktop.
JsonML with Jayrock
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; | |
using System.IO; | |
using System.Xml; | |
using Jayrock.Json; | |
using Jayrock.JsonML; | |
// See: http://groups.google.com/group/jayrock/t/50be3a3931c39f78 | |
public class Program | |
{ | |
public static void Main() | |
{ | |
const string @xml = @" | |
<div id='demo' class='JSONML'><p>JSONML is a transformation | |
between<b>JSON</b>and<b>XML</b>that preserves ordering of document | |
features.</p><p>JSONML can work with JSON arrays or JSON | |
objects.</p><p>Three<br/>little<br/>words</p></div>"; | |
StringWriter jsonw = new StringWriter(); | |
new JsonMLEncoder().Encode( | |
new XmlTextReader(new StringReader(xml)), | |
new JsonTextWriter(jsonw)); | |
Console.WriteLine(jsonw); | |
StringWriter xmlw = new StringWriter(); | |
new JsonMLDecoder().Decode( | |
new JsonTextReader(new StringReader(jsonw.ToString())), | |
new XmlTextWriter(xmlw)); | |
Console.WriteLine(xmlw); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment