Return a jsonified string represenation of obj if obj is jsonifiable else
    return obj untouched
347934
def object(obj):
    
    if isinstance(obj, dict) or isinstance(obj, list):
        return json.dumps(obj)
    return obj
758509
def to_json(obj):
    """"""
    i = StringIO.StringIO()
    w = Writer(i, encoding='UTF-8')
    w.write_value(obj)
    return i.getvalue()
140956
def _serialize(self, value, attr, obj, **kwargs):
        """"""
        ret = self._validated(value)
        return (
            self._to_string(ret)
            if (self.as_string and ret not in (None, missing_))
            else ret
        )
965373
def value_to_string(self, obj):
        """"""
        try:
            return force_unicode(self.__get__(obj))
        except TypeError:
            return str(self.__get__(obj))
838987
function jPretty(obj) {
  // make sure data is a json obj
  if(typeof obj === "string") {
    obj = obj.replace(/\s/g,"");
    obj = obj.replace(/'/g,'"');
  }
  let gl;
  try {
    
    const p = JSON.parse(obj); 
    gl = obj; // already stringified
  } catch (e) { // not stringified
      if(typeof obj === "string") {
        obj = obj.replace(/([,|{|\s|])([a-zA-Z0-9]*?)([\s|]*\:)/g,'$1"$2"$3');
      }

      const s = JSON.stringify(obj);
      const k = JSON.parse(JSON.stringify(obj));
       if (k && typeof k === 'object') {
        gl = s;
      } else {
        if(typeof obj === "string") {
        //console.log("ERROR: " + );
        obj = obj.replace(/"/g,"'");
        obj = obj.replace(/'/g,'"');
        
        gl = ((obj));
        } else {
          return new Error(`jpretty: input is not recognised json: ${typeof obj}- ${JSON.stringify(obj)}`);
        }
      }
  }

  return (() => {
    let jp = prettyJson(gl); 
    if(typeof window !== 'undefined') {
      console.log("jPretty loaded in browser");
        jp = jp.replace(/\{\}/g,"<br/>{}");
    }
    return jp;
  })()
}
254712
def object_to_json(obj, indent=2):
    
    instance_json = json.dumps(obj, indent=indent, ensure_ascii=False, cls=DjangoJSONEncoder)
    return instance_json
403142
def runGetRequest(self, obj):
        
        protocolElement = obj.toProtocolElement()
        jsonString = protocol.toJson(protocolElement)
        return jsonString
425460
def _default_json_default(obj):
    
    if isinstance(obj, (datetime.datetime, datetime.date, datetime.time)):
        return obj.isoformat()
    else:
        return str(obj)
8733
def dump_json(obj):
    """"""
    return simplejson.dumps(obj, ignore_nan=True, default=json_util.default)
53009
function toStringJSON (str) {
  if (isObject(str)) {
    return str
  } else if (isString(str)) {
    try {
      return JSON.parse(str)
    } catch (e) {}
  }
  return {}
}
1313808
def _get_pretty_string(obj):
    
    sio = StringIO()
    pprint.pprint(obj, stream=sio)
    return sio.getvalue()
245503
def object_to_json(obj):
    """"""
    if isinstance(obj, (datetime.datetime, datetime.date, datetime.time)):
        return obj.isoformat()
    return str(obj)
1144626
def jsonify(obj, status=200, headers=None, refs=False, encoder=JSONEncoder):
    
    if encoder is JSONEncoder:
        data = encoder(refs=refs).encode(obj)
    else:
        data = encoder().encode(obj)
    if 'callback' in request.args:
        cb = request.args.get('callback')
        data = '%s && %s(%s)' % (cb, cb, data)
    return Response(data, headers=headers,
                    status=status,
                    mimetype='application/json')
500322
def json_serial(obj):
    """"""
    if isinstance(obj, LegipyModel):
        return obj.to_json()
    elif isinstance(obj, (datetime.date, datetime.datetime)):
        return obj.isoformat()
    raise TypeError("Type {0} not serializable".format(repr(type(obj))))
439073
function objectify (obj) {
  return JSON.parse(JSON.stringify(obj, Object.getOwnPropertyNames(obj)))
}
1324488
def serialize(obj):
    """"""
    if isinstance(obj, datetime.datetime):
        serial = obj.isoformat(sep='T')
        return serial

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

    try:
        return obj.__dict__
    except AttributeError:
        return str(obj)
    except Exception as e:
        strval = 'unknown obj'
        exceptval = 'unknown err'
        try:
            strval = str(obj)
            exceptval = repr(e)
        except Exception:
            pass
        return 'json fail {} {}'.format(exceptval, strval)
373528
def json_serial(cls, obj):
        """"""

        if isinstance(obj, datetime):
            serial = obj.isoformat()

        elif issubclass(obj.__class__, enum.Enum):
            serial = obj.value

        elif isinstance(obj, timedelta):
            serial = str(obj)

        elif isinstance(obj, set):
            serial = list(x for x in obj)

        elif isinstance(obj, uuid.UUID):
            serial = str(obj)

        # FIXME: if you want to add one more custom serializer, think twice about `singledispatch`

        else:
            raise TypeError("Type not serializable %s in %s" % (type(obj), obj))

        return serial