Add utils to support builder pattern for creating JSON objects.

This permits building JSON objects with a lot less casting (or temporary
variables).

Updated example Java apps to show how the builder can be used.

@kislyuk or anyone else who feels like thinking about the API for Java developers.