Improved saveAsJSON and moved to FileTools