Convert instance to JSON
431923
def to_json(value, **kwargs):
        """"""
        if isinstance(value, HasProperties):
            return value.serialize(**kwargs)
        try:
            return json.loads(json.dumps(value))
        except TypeError:
            raise TypeError(
                "Cannot convert type {} to JSON without calling 'serialize' "
                "on an instance of Instance Property and registering a custom "
                "serializer".format(value.__class__.__name__)
            )
329955
def to_json(self, **kwargs: Mapping) -> str:
        
        content = {
            'Header': dict(self.Header),
            'Reads': self.Reads,
            'Settings': dict(self.Settings),
            'Data': [sample.to_json() for sample in self.samples],
            **{title: dict(getattr(self, title)) for title in self._sections},
        }
        return json.dumps(content, **kwargs)
649924
function (instance, instanceKey, type, json, jsonKey) {
    var jsonObject = (jsonKey !== undefined) ? (json[jsonKey] || []) : json;
    var jsonArraySize = jsonObject.length;
    var conversionFunctionsList = [];
    var arrayInstance = [];
    instance[instanceKey] = arrayInstance;
    if (jsonArraySize > 0) {
        for (var i = 0; i < jsonArraySize; i++) {
            if (jsonObject[i]) {
                var typeName = getTypeNameFromInstance(type);
                if (!isSimpleType(typeName)) {
                    var typeInstance = new type();
                    conversionFunctionsList.push({ functionName: Constants.OBJECT_TYPE, instance: typeInstance, json: jsonObject[i] });
                    arrayInstance.push(typeInstance);
                }
                else {
                    arrayInstance.push(conversionFunctions[Constants.FROM_ARRAY](jsonObject[i], typeName));
                }
            }
        }
    }
    return conversionFunctionsList;
}
476749
def _as_json(self, **kwargs) -> str:
        
        return json.dumps(self, default=self._default, **kwargs)
140008
def serialize_instance(instance):
    
    model_name = force_text(instance._meta)
    return '{}:{}'.format(model_name, instance.pk)
434460
def to_json(self):
        
        endpoints = []
        for endpoint in self.endpoints:
            list_fields = endpoint.fields
            resource_type = endpoint.Meta.resource_type
            table = endpoint.Meta.table

            data = endpoint.to_dict()
            data['fields'] = resource_type.get_type_of_fields(
                list_fields,
                table,
            )
            endpoints.append(data)

        data = {
            'title': self.title,
            'endpoints': sorted(endpoints, key=lambda x: x['name']),
        }

        return json.dumps(data)
758509
def to_json(obj):
    """"""
    i = StringIO.StringIO()
    w = Writer(i, encoding='UTF-8')
    w.write_value(obj)
    return i.getvalue()
924189
def toJson(self, data=None, pretty=False):
        """"""
        if data==None: data = self.attrs
        data = self.flatten(data) # don't send objects as str in json
        #if pretty:
        ret = json.dumps(data, indent=4, sort_keys=True)
        #self.inflate() # restore objects from json str data
        return ret
33046
def as_json(_options = {})
      {
        resource_owner_id: resource_owner_id,
        scope: scopes,
        expires_in: expires_in_seconds,
        application: { uid: application.try(:uid) },
        created_at: created_at.to_i,
      }
    end
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)
378171
def as_json(self, ensure_ascii=False):
        """"""
        return json.dumps(self.as_dict, ensure_ascii=ensure_ascii)
939079
def json_data(self, instance, default=None):
        
        value = self.get(instance)
        if value and self.is_multi_valued():
            return map(api.get_url_info, value)
        elif value and not self.is_multi_valued():
            return api.get_url_info(value)
        return value or default
1084362
def to_json(obj):
    
    try:
        return json.dumps(obj, default=lambda obj: {k.lower(): v for k, v in obj.__dict__.items()},
                          sort_keys=False, separators=(',', ':')).encode()
    except Exception as e:
        logger.info("to_json: ", e, obj)
684025
public String asJson(T instance) throws JAXBException {
    Marshaller marshaller = getMarshaller(instance);
    marshaller.setProperty(MarshallerProperties.MEDIA_TYPE, "application/json");
    marshaller.setProperty(MarshallerProperties.JSON_INCLUDE_ROOT, true);
    String result = getString(marshaller, instance);
    return result;
  }
1123195
def json_data(self, instance, default=[]):
        
        value = self.get(instance)
        out = map(api.get_url_info, value)
        return out or default
1208210
def to_json(value, **kwargs):
        """"""
        if isinstance(value, HasProperties):
            return value.serialize(**kwargs)
        return value
860793
def json_data(self, instance, default=None):
        
        value = self.get(instance)
        if not value:
            return ""
        if callable(value):
            value = value()
        return api.to_iso_date(value, default=default)