JSON generation almost complete