Converts a suds object to a JSON string.
    :param obj: suds object
    :param key_to_lower: If set, changes index key name to lower case.
    :return: json object
494443
def sobject_to_json(obj, key_to_lower=False):
    
    import json
    data = sobject_to_dict(obj, key_to_lower=key_to_lower, json_serialize=True)
    return json.dumps(data)
668862
function _sortObj(obj) {
        if (!_.isObject(obj)) {
            return JSON.stringify(obj);
        }

        if (_.isArray(obj)) {
            return '[' + _(obj).map(_sortObj).join(',') + ']';
        }

        return '{' +
            _(obj)
                .keys()
                .sort()
                .map(function (key) {
                    return JSON.stringify(key) + ':' + _sortObj(obj[key]);
                })
                .join(',') +
            '}';
    }
529919
def obj_cursor_to_json(self, cursor):
        
        json_object = json.loads(json_util.dumps(cursor))

        if "_id" in json_object:
            json_object['id'] = str(json_object['_id']['$oid'])
            del json_object['_id']

        return json_object
1315836
def to_json(self, *, include_keys=None, exclude_keys=None, use_default_excludes=True,
              pretty=False):
    
    return to_json(
      self.to_dict(
        include_keys=include_keys,
        exclude_keys=exclude_keys,
        use_default_excludes=use_default_excludes),
      pretty=pretty)
1080098
def json_formatter(obj):
    
    if isinstance(obj, str):
        # Make a list of size 1
        return json.dumps([obj], indent=True)
    else:
        return json.dumps(obj, indent=True, sort_keys=True)
1241952
def to_json(obj, indent=4, sort_keys=True, **kwargs):
    
    obj_dict = to_dict(obj, **kwargs)
    return json.dumps(obj_dict, indent=indent, sort_keys=sort_keys)
726170
def to_json(self, indent=None, sort_keys=True):
        
        return json.dumps(self.to_dict(), indent=indent, sort_keys=sort_keys)
271746
def serialize(obj):
    
    LOGGER.debug('serialize(%s)', obj)

    if isinstance(obj, datetime.date):
        return simplejson.dumps(obj, default=encoders.as_date)

    elif hasattr(obj, '__dict__'):
        return simplejson.dumps(obj, default=encoders.as_object)

    return simplejson.dumps(obj)
261718
def _to_key(d):
        """"""
        as_str = json.dumps(d, sort_keys=True)
        return as_str.replace('"{{', '{{').replace('}}"', '}}')
28854
def json_default(obj):
    
    if isinstance(obj, datetime):
        return obj.strftime("%Y-%m-%d %H:%M:%S")
    elif isinstance(obj, Decimal):
        return float(obj)
    elif isinstance(obj, uuid.UUID):
        return text_type(obj)
    else:
        try:
            return text_type(obj)
        except:
            pass

    raise TypeError("%r is not JSON serializable" % obj)
821593
def get_id2lower(objs):
    """"""
    id2lower = {}
    for obj in objs:
        _get_id2lower(id2lower, obj.item_id, obj)
    return id2lower
952393
def json_encode(obj, serialize):
    
    if hasattr(obj, 'to_dict'):
        return obj.to_dict(serialize=serialize)
    elif isinstance(obj, datetime):
        return obj.date().isoformat()
    elif isinstance(obj, date):
        return obj.isoformat()
    elif isinstance(obj, ProxyDict):
        return dict(obj)
    elif isinstance(obj, ProxyList):
        return list(obj)
    elif is_iterable_but_not_string(obj):
        return list(obj)
340728
def to_dict(cls, obj):
        '''
        '''
        return {
            k: getattr(obj, k)
            for k in dir(obj)
            if cls.serialisable(k, obj)
        }
557783
def obj_to_string(obj):
    ''''''
    if not obj:
        return None
    elif isinstance(obj, bytes):
        return obj.decode('utf-8')
    elif isinstance(obj, basestring):
        return obj
    elif is_lazy_string(obj):
        return obj.value
    elif hasattr(obj, '__html__'):
        return obj.__html__()
    else:
        return str(obj)
351260
public static String toJson(Object obj) {
		try {
			return objectMapper.writeValueAsString(obj);
		} catch (JsonProcessingException e) {
			throw new RuntimeException(e);
		}
	}
418091
function o2s(obj) {
    var s = "";
    for (key in obj) {
        var line = key + "->" + obj[key];
        line.replace("\n", " ");
        s += line + "\n";
    }
    return s;
}
569475
def to_json(fn, obj):
    
    with open(fn, 'w') as f:
        json.dump(obj, f, cls=OperatorEncoder, indent=2, ensure_ascii=False)
    return fn