code: def to_json(self, version=Version.latest):
          
          return json.dumps(self.as_version(version))
docs: Tries to convert an object into a JSON representation and return
          the resulting string
  
          An Object can define how it is serialized by overriding the as_version()
          implementation. A caller may further define how the object is serialized
          by passing in a custom encoder. The default encoder will ignore
          properties of an object that are None at the time of serialization.
  
          :param version: The version to which the object must be serialized to.
          This will default to the latest version supported by the library.
          :type version: str | unicode