Improved JSON string building