function jsonRepresentation(elem) { this.elem = elem; this.template = elem.getElementsByClassName('template')[0]; this.plant = function (arr, childKey) { var a = this.plantProcess(arr, childKey); for (var i in a) this.elem.appendChild(a[i]); } this.plantProcess = function (arr, childKey) { var ret = new Array(); var tmp = null; for ( var i in arr ) { tmp = this.grow(arr[i]); if (arr[i][key]) { var a = this.plant(arr[i][j], childKey); for ( var k in a ) { ret.appendChild(a[k]); } } ret[ret.length] = tmp; } return ret; } this.grow = function (fsitem) { var node = this.template(true); for ( var i in fsitem ) { if ( i == 'class' ) node.addClassName(fsitem[i]); else node[i] = fsitem[i]; } return node; } } function template(elem) { this.elem = elem; this.template = elem.getElementsByClassName('template')[0]; this.plant = function (arr, childKey) { var a = this.plantProcess(arr, childKey); for (var i in a) this.elem.appendChild(a[i]); } this.plantProcess = function (arr, childKey) { var ret = new Array(); var tmp = null; for ( var i in arr ) { tmp = this.grow(arr[i]); if (arr[i][key]) { var a = this.plant(arr[i][j], childKey); var b = document.createNode( this.elem.tagName ); tmp.appendChild(b); for ( var k in a ) { b.appendChild(a[k]); } } ret[ret.length] = tmp; } return ret; } this.grow = function (fsitem) { var node = this.template.cloneNode(true); for ( var i in fsitem ) { if ( i == 'class' ) node.addClassName(fsitem[i]); else node[i] = fsitem[i]; } return node; } } function pk(respo) { var json = eval(respo.text); var x = new jsonRepresentation(document.getElementById('json')); } var code = ' include("fileclass.php"); $x = new DSDirectory("."); echo json_encode( $x->lister(2) ); '; var q = new xhrQuery('phpC.php', 'POST'); q.addPost('code', code); q.callback = pk; xhrProc.process(q); function walk(key, func, arr) { var str = ''; var x = new Array(); for ( var i in arr ) { if (i == key) { str += "\t=>\t{" + formes( "\n" + walk(key, func, arr[i] ) ) + "}"; } else { str += i + "\t=>\t" + arr[i]; } str += "\n"; } return str; }