Better json serialization.

Implement canonical types.
Rename basic types to primitive types.