java: extracted Codec interface so non-JSON formats could be added in
the future