What it is

A pruning JSON.stringify for the very specific cases where you need to be able to stringify big or recursive javascript objects and don't really need the result to be complete.

var json = JSON.stringify(window); // this fails

var json = JSON.prune(window); // this builds a JSON valid string from a pruned version of the recursive, deep, and not totally accessible window object

var prunedWindow = JSON.parse(JSON.prune(window)); // this builds a lighter and not recursive version of window

	

It's totally useless for at least 99% js developpers.

JSON.prune.log is a proxy over console.log deep cloning the objects before logging them, in order to avoid the delay problem encountered on non primitive objects logging (see here for example).

JSON.prune.log('some object:', window); 
	

You should not use it frequently, only when you really need to see the objects how they were at logging time.

Include it

You may download JSON.prune.js and include it from your site.
Or you may include the file directly from my server :
<script src=http://dystroy.org/JSON.prune/.js></script>

Links

Test it in the console

Open the console and type lines like the following ones :
JSON.prune({a:1, b:[1, 2, 3]});
JSON.prune(window);
JSON.prune(window.location,{inheritedProperties: true}); // without this setting, FireFox and IE only show an empty object
var a=[]; for (var i=0;i<1000;i++) {a.push(i<2?1:a[i-2]+a[i-1])} JSON.prune(a, 0, 200);
	

Test it in the page