Generating json more properly