optimized json generation