Implemented serialization to json.