Add $json flag to generate()

Reads format option in config, if json, will output json, otherwise php
This could be more generalized to output more types, if more than just php and json desired