Implement json serialize/deserialize.