Home > Articoli > JSON, graphs and Apache Sling

JSON, graphs and Apache Sling

Yesterday I was looking an interesting javascript library, JIT (JavaScript InfoVis Toolkit), that is really useful to create some cool rappresentation of your data with graphs, trees, charts and so on.

This toolkit creates different data rappresentation using JSON as input, so I thought it could be funny to integrate with Apache Sling to have a new rappresentation of my repository.

Unfortunately JSON translation in Apache Sling is a bit different from the one used in JIT, because it needs children node rappresented as an array (not in every demo contained in JIT but in the one I want so integrate with Sling).

So I modified org.apache.sling.commons.json.jcr.JsonItemWriter , to encapsulate the nodes in a JSON array

Iterator children = resource.listChildren();
if (children.hasNext()) {
	while (children.hasNext()) {
		Resource n = children.next();
		log.info("Giro "+n.getName());

Now I have to load some data on my instance of Apache Sling, so I create a simple JSON.

	"id": "node01",
	"name": "0.2",
	"data": "",
	"node11": {
		"id": "node13",
		"name": "1.3",
		"data": "",
		"node111": {

Finally I have to load this data into JIT, so I modified an example to load JSON data from an external source

function init() {
		url: "http://localhost:8080/repository.infinity.json",
		success: postInit

So I got a very cool rappresentation of my data stored with JCR

  1. marc
    15 ottobre 2010 alle 21:35

    Could you provide the org.apache.sling.commons.json.jcr.JsonItemWriter modified ?

  1. No trackbacks yet.


Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google+ photo

Stai commentando usando il tuo account Google+. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )


Connessione a %s...

%d blogger hanno fatto clic su Mi Piace per questo: