Commenting JSON files

This isn't quite an AngularJS hack per se, but when you are writing JSON configuration files (for example, in your Grunt configuration, Bower package definition, or npm package definition), you might find that you forgot the purpose of a line. Inconveniently, JSON does not support formal comments, but there are some clever (but highly controversial) workarounds that can be used with a pinch.

How to do it…

If the JSON file is parsed in a certain way, you can take advantage of that by allowing the data format to bleed outside the boundaries of the JSON specification.

Ignored properties

If you know that a section of JSON won't be exhaustively parsed, that is, there is a defined set of keys that it will examine, then the easiest ...

Get AngularJS Web Application Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.