Add compare, json encoding, and repr()

Convenience functions