Convert an object into its JSON representation.
358773
private static String toJson(Object x) {
    try {
      if (x == null || x instanceof String || x instanceof Number || x instanceof Character
          || x.getClass().isArray() || x instanceof Iterable<?>) {
        return new JSONObject().put("JSON", x).toString(2);
      } else if (x instanceof Map<?, ?>) {
        return (new JSONObject((Map<?, ?>) x)).toString(2);
      } else if (x instanceof JSONObject) {
        return ((JSONObject) x).toString(2);
      } else {
        return (new JSONObject(x)).toString(2);
      }
    } catch (Exception e) {
      throw new RuntimeException("x=" + x, e);
    }
  }
602662
def to_json(self) -> Mapping:
        
        return {str(x): str(y) for x, y in self.items()}
776193
def to_json(self, *args, **kwargs):
        """"""
        return json.dumps(self.serialize(), *args, **kwargs)
8733
def dump_json(obj):
    """"""
    return simplejson.dumps(obj, ignore_nan=True, default=json_util.default)
167992
def from_json(cls, data):
        """"""
        # Decode JSON string
        assert isinstance(data, str)
        data = json.loads(data)
        assert isinstance(data, dict)
        return cls.from_dict(data)
446537
def json_obj(self, method, params=None, auth=True):
        """"""
        if params is None:
            params = {}

        obj = {
            'jsonrpc': '2.0',
            'method': method,
            'params': params,
            'auth': self.__auth if auth else None,
            'id': self.id,
        }

        return json.dumps(obj)
348957
def to_output(self, value):
        """"""
        return json.loads(resolwe_runtime_utils.save(self.name, str(value)))
10436
def to_dict(obj):
    
    d = _to_json_type(obj)
    if isinstance(d, dict):
        return scrub_dict(d)
    else:
        raise ValueError("The value provided must be an object.")
969297
def encode(obj):
    
    if hasattr(obj, 'json'):
        return obj.json
    if hasattr(obj, '__json__'):
        return obj.__json__()
    return dumps(obj)
388169
def _encode_json(obj):
    '''
    
    '''
    def _dump_obj(obj):
        if isinstance(obj, dict):
            return obj
        d = dict()
        for k in dir(obj):
            if not k.startswith('_'):
                d[k] = getattr(obj, k)
        return d
    return json.dumps(obj, default=_dump_obj)
226646
def _to_json(self):
        
        return dict(( (k, v) for k, v in self.__dict__.iteritems() if k != 'server'))
1241829
def to_json(self):
        """"""
        return {'year': self.year,
                'month': self.month,
                'day': self.day,
                'hour': self.hour,
                'minute': self.minute}
327743
def json_to_model(self, model_name, j, validate=False):
        """"""
        if validate:
            self.api_spec.validate(model_name, j)
        return self.api_spec.json_to_model(model_name, j)
579178
def json_dumps(self, obj):
        """"""
        return json.dumps(obj, sort_keys=True, indent=4, separators=(',', ': '))
378171
def as_json(self, ensure_ascii=False):
        """"""
        return json.dumps(self.as_dict, ensure_ascii=ensure_ascii)
998734
def json_dumps(cls, obj, **kwargs):
        
        if 'cls' not in kwargs:
            kwargs['cls'] = cls.json_encoder
        return json.dumps(obj, **kwargs)
254014
def to_json(self, *args, **kwargs):
    '''
    '''
    try:
      import ujson as json
    except ImportError:
      import json
    return json.dumps(self.serialized, *args, **kwargs)