Converts an object to JSON, using the defaults specified in register_json_default.

  :obj: the object to convert to JSON
  :pretty: if True, extra whitespace is added to make the output easier to read
338374
def to_json(obj, pretty=False):
  
  sort_keys = False
  indent = None
  separators = (",", ":")

  if isinstance(pretty, tuple):
    sort_keys, indent, separators = pretty
  elif pretty is True:
    sort_keys = True
    indent = 2
    separators = (", ", ": ")

  return json.dumps(obj, sort_keys=sort_keys, indent=indent, separators=separators,
                    default=json_default)
471736
def to_json(obj, seen=None):
    

    if not seen:
        seen = []

    properties = list(class_mapper(type(obj)).iterate_properties)
    relationships = [
        p.key for p in properties if type(p) is RelationshipProperty
    ]
    attrs = [
        p.key for p in properties if p.key not in relationships
    ]

    d = dict([(attr, getattr(obj, attr)) for attr in attrs])

    for attr in relationships:
        d[attr] = expand(obj, getattr(obj, attr), seen)

    return d
642514
def _to_json_default(obj):
    
    # Datetime
    if isinstance(obj, datetime.datetime):
        return obj.isoformat()

    # UUID
    if isinstance(obj, uuid.UUID):
        return str(obj)

    # numpy
    if hasattr(obj, 'item'):
        return obj.item()

    # # Enum
    # if hasattr(obj, 'value'):
    #     return obj.value

    try:
        return obj.id
    except Exception:
        raise TypeError('{obj} is not JSON serializable'.format(obj=repr(obj)))
254712
def object_to_json(obj, indent=2):
    
    instance_json = json.dumps(obj, indent=indent, ensure_ascii=False, cls=DjangoJSONEncoder)
    return instance_json
1234919
def pretty_json(data):
    
    data = json.loads(data.decode('utf-8'))
    return json.dumps(data, indent=4, sort_keys=True)
243460
def to_json(object, use_alias = false)
      hash = to_hash(object, use_alias)
      JSON.dump(hash)
    end
91339
def json_data(self, instance, default=None):
        
        value = self.get(instance)
        if value:
            return value.output
        return value
722212
def encode_json(self, serializable):
        
        return json.dumps(serializable.serialize(), cls=self.encoder)
983101
def to_json(self, indent=2):
        
        return json.dumps(self, default=json_encode_for_printing, indent=indent)
758509
def to_json(obj):
    """"""
    i = StringIO.StringIO()
    w = Writer(i, encoding='UTF-8')
    w.write_value(obj)
    return i.getvalue()
1218037
def dumps(obj, *args, **kwargs):
    '''  '''
    return json.dumps(obj, *args, cls=TypelessSONEncoder, ensure_ascii=False, **kwargs)
703667
def set_json(self, obj, status=HttpStatusCodes.HTTP_200):
        
        obj = json.dumps(obj, sort_keys=True, default=lambda x: str(x))
        self.set_status(status)
        self.set_header(HttpResponseHeaders.CONTENT_TYPE, 'application/json')
        self.set_content(obj)
911025
def from_json(cls, obj):
        
        if len(obj) == 2:
            (field, operator) = obj
            return cls(field, operator)
        if len(obj) > 2:
            (field, operator, value) = obj
            return cls(field, operator, value)
138889
def to_json(self, pretty=True):
        
        data_dict = self.to_dict()
        if pretty:
            return json.dumps(
                data_dict, sort_keys=True, indent=2)
        return json.dumps(data_dict, sort_keys=True)
42556
def to_json(self, model):
        
        # Get the basic Json object from the super class
        obj = super(DefaultModelRegistry, self).to_json(model)
        # Add model parameter
        obj['parameters'] = [
            para.to_json() for para in model.parameters
        ]
        obj['outputs'] = model.outputs.to_json()
        return obj
40244
def to_json(opts={})
      hsh = self.to_ordered_hash(opts)
      if opts.fetch(:pretty, false)
        JSON.pretty_generate(hsh)
      else
        hsh.to_json
      end
    end
476749
def _as_json(self, **kwargs) -> str:
        
        return json.dumps(self, default=self._default, **kwargs)