First version of generateJSON