Publishing Safely from a JSON Content File
A JSON content file can hold site metadata, article paragraphs, and release notes while the application owns routing and presentation. Keeping paragraphs as plain strings makes the publishing format easy to inspect and avoids treating editorial content as executable markup. JSON syntax validation alone, however, only proves that the file can be parsed.
Content validation should check the expected object structure, required fields, string and array types, and reasonable size limits. Article slugs should be unique and restricted to an intentional format. Dates need both the expected YYYY-MM-DD shape and calendar validity, since a matching string can still describe an impossible date.
Plain text must be escaped when it is inserted into HTML. Characters such as ampersands and angle brackets have special meaning in text contexts, and quoted attributes require their own safe handling. JSON parsing does not perform HTML escaping. URL values also need validation for their destination context rather than relying on escaping alone.
A contact destination can be built from a validated email address using the mailto scheme, while its visible label remains ordinary escaped text. Keeping the address in one site field helps prevent inconsistent contact information. The renderer should apply these rules centrally so an article title, paragraph, or release note cannot bypass them.
Content hot reload should validate a complete candidate before replacing the active snapshot. Writing a temporary file and atomically renaming it on the same filesystem can prevent readers from observing a partially written update. If a reload fails, retaining the last valid snapshot and reporting the error is safer than replacing it with broken content; each request should use one consistent snapshot.