create JSON representations of DOM DocumentFragments an vice versa with JavaScript