Structure-aware JSON-based document templating