Add $json flag to generate()