Refactor JSON serialization

Write Annotation to JSON with a minimum of repeated code.