def to_json(self, pretty_print=False): """Serializes the sample to a JSON string. Args: pretty_print (False): whether to render the JSON in human readable format with newlines and indentations Returns: a JSON string """ return etas.json_to_str(self.to_dict(), pretty_print=pretty_print)
def to_json(self, pretty_print=False): """Serializes the document to a JSON string. Args: pretty_print (False): whether to render the JSON in human readable format with newlines and indentations Returns: a JSON string """ d = self.to_dict(extended=True) return etas.json_to_str(d, pretty_print=pretty_print)
def execute(parser, args): if args.locate: if os.path.isfile(foc.FIFTYONE_CONFIG_PATH): print(foc.FIFTYONE_CONFIG_PATH) else: print("No config file found at '%s'.\n" % foc.FIFTYONE_CONFIG_PATH) return if args.field: field = getattr(fo.config, args.field) if etau.is_str(field): print(field) else: print(etas.json_to_str(field)) else: print(fo.config)
def to_json(self, rel_dir=None, pretty_print=False): """Returns a JSON string representation of the collection. The samples will be written as a list in a top-level ``samples`` field of the returned dictionary. Args: rel_dir (None): a relative directory to remove from the ``filepath`` of each sample, if possible. The path is converted to an absolute path (if necessary) via ``os.path.abspath(os.path.expanduser(rel_dir))``. The typical use case for this argument is that your source data lives in a single directory and you wish to serialize relative, rather than absolute, paths to the data within that directory pretty_print (False): whether to render the JSON in human readable format with newlines and indentations Returns: a JSON string """ return etas.json_to_str(self.to_dict(rel_dir=rel_dir), pretty_print=pretty_print)