Translate

Thursday, January 8, 2015

JSON Transformation via XML and XSLT (JsonXslt)

Recently, I tried to look for a way to transform JSON to another JSON object. Surprisingly, I did not find anything like this. I'm pretty familiar with XSLT, so I figured that could be a good way to transform between JSON objects.

So, I created my first public github project: https://github.com/kuhnboy/JsonXslt.

This project provides currently two classes:

1) JsonXPathNavigator (either used with XsltCompiledTransform to use as the source of an XSLT transformation or can be loaded into an XDocument or XmlDocument via the ReadSubtree method).
2) XmlJsonReader (subclass of the Newtonsoft JsonReader, allowing you to load an XDocument into a JObject via JObject.Load).

Of course there are a few limitations because JSON and XML are quite different, but it's a start. You should be able to do things like convert JSON -> HTML via XSLT.

Edit: The JsonXslt package is currently available on NuGet and I have added a JSON -> HTML example on GitHub.

No comments:

Post a Comment

Codementor

Ryan Kuhn

★★★★★

Expertise