Monday, February 6th, 2006

Transforming JSON

Category: JavaScript, Utility

Stefan Gössner has seen a need to transform the JSON format, similarly how we transform XML via XSLT.

The implementation of JSON/T is by writing rules in JSON format itself.


Given a JSON object such as:


  1. { "link": {"uri":"", "title":"company homepage" }}

and transform it to:

  1. <a href="">company homepage</a>

The JSON/T rule for doing this:


  1. { "link": "<a href=\"{link.uri}\">{link.title}</a>" }

You can download a JavaScript version of the JSON/T processor

Posted by Dion Almaer at 9:16 am

3.7 rating from 17 votes


Comments feed TrackBack URI

It’s funny how the JSON/T rule looks different in my feed reader than on this page. In my feed reader it did not make sense, but here it does.

Comment by Hermann Klinke — February 6, 2006

In a similar vein, I wrote a json2dom script about a week ago. I don’t know if it has any practical application (probably not), but I wanted a way to create HTML elements from an Ajax response without using innerHTML, and this is what I came up with.

Comment by Randy Boland — February 6, 2006

[…] I first read about this over on Ajaxian and Randy Boland commented to say that he’s done a JSON to DOM script as well. […]

Pingback by Migrating to JSON » Web 2.0 Blog — February 8, 2006

One major different between XSLT and a JSON transformer is that the later need to have a grammar for object/hash enumeration, I wonder whether JSONT support it, which I found lost in many js template engine.

Comment by yaojun85 — July 18, 2008

Leave a comment

You must be logged in to post a comment.