Fix generating and consuming JSON Fixes #2