Note that a new prettyPrint() is there to output your JSON in an eye-pleasing way.

Tranformers

… robots in disguise. Sorry.

“Transformers allow you to register classes that participate in serializing fields. It’s best understood as described by a use case. Say we have an object that represents an email, and we want to send it to the browser over JSON. But, emails can have illegal characters for HTML like < or > in fields like the to, from, or cc portions. Before we would have to create a separate method that would HTML encode those characters, and exclude the method that returned those values in plain text. Now we can register a transformer for those fields on the fly. Here’s how we can solve this problem:”