Serialize an extras key, value pair into JSON-LD
330342
def get_json_ld_extra(key, value):
    ''''''
    value = value.serialize() if hasattr(value, 'serialize') else value
    return {
        '@type': 'http://schema.org/PropertyValue',
        'name': key,
        'value': value,
    }
109827
def get_extra_data(self, data):
        """"""
        result = {}
        for key in list(data.keys()):
            if key.startswith(self.ctype + '-'):
                new_key = key.replace(self.ctype + '-', '')
                result[new_key] = data[key]
        return result
305248
def json(
        self,
        *,
        include: 'SetStr' = None,
        exclude: 'SetStr' = None,
        by_alias: bool = False,
        skip_defaults: bool = False,
        encoder: Optional[Callable[[Any], Any]] = None,
        **dumps_kwargs: Any,
    ) -> str:
        
        encoder = cast(Callable[[Any], Any], encoder or self._json_encoder)
        return json.dumps(
            self.dict(include=include, exclude=exclude, by_alias=by_alias, skip_defaults=skip_defaults),
            default=encoder,
            **dumps_kwargs,
        )
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
47569
def to_json(self, skip_nulls=True):
        """"""
        return json.dumps(self.to_dict(skip_nulls=skip_nulls))
488618
function (key, instance, serializer) {
    var value = serializer.serialize(instance);
    if (key !== undefined) {
        return "\"" + key + "\":" + value;
    }
    else {
        return value;
    }
}
565003
def dumps(obj):
    """"""
    return json.dumps(obj, indent=4, sort_keys=True, cls=CustomEncoder)
236213
def save_json(object, handle, indent=2):
    """"""
    obj_json = json.dumps(object, indent=indent, cls=NumpyJSONEncoder)
    handle.write(obj_json)
444799
def _encode(self):
        """"""
        obj = {k: v for k, v in self.__dict__.items()
               if not k.startswith('_') and type(v) in SAFE_TYPES}
        obj.update({k: v._encode() for k, v in self.__dict__.items()
                   if isinstance(v, Ent)})
        return obj
941094
def as_json(options = {})
      root = options.key?(:root) ? options[:root] : true
      hash = if root && root_name
               { root_name => serializable_hash }
             else
               serializable_hash
             end
      hash[meta_key] = @options[:meta] if @options.key?(:meta)
      hash
    end
277248
def store_json(self, filename, dict_to_store):
        """"""
        filename = os.path.join(
            self.data_dir,
            filename + '.data'
        )
        fileops.dump_dict_to_file(
            dict_to_store,
            filename
        )
159410
def serialize(self, value, **kwargs):
        """"""
        return [self.item_type.serialize(val, **kwargs) for val in value]
1293513
def _jsonify(x):
    """"""
    if isinstance(x, dict_class):
        return json.dumps(x._d, separators=(',', ':'))
    return json.dumps(x, separators=(',', ':'))
384516
def to_json(self, obj, host=None, indent=None):
        """"""
        if indent:
            return json.dumps(deep_map(lambda o: self.encode(o, host), obj),
                              indent=indent)
        else:
            return json.dumps(deep_map(lambda o: self.encode(o, host), obj))
459484
def get_extra_data(self, data):
        """"""
        result = {}
        for key in data.keys():
            if key.startswith(self.name + '-'):
                new_key = key.replace(self.name + '-', '')
                result[new_key] = data[key]
        return result
803928
function deserialize(json) {
        var data, deserialized;

        var includedMap = {};
        each(json.included, function(value) {
            var key = value.type + '-' + value.id;
            includedMap[key] = value;
        });

        if (isArray(json.data)) {
            data = map(
                json.data,
                function(record) {
                    populateRelatedFields(record, includedMap);
                    return flatten(record);
                }
            );
        }
        else if (isObject(json.data)) {
            populateRelatedFields(json.data, includedMap);
            data = flatten(json.data);
        }

        deserialized = {
            data: data,
            jsonapi: json.jsonapi || {}
        };

        if (json.meta) {
            deserialized.meta = json.meta;
        }

        if (json.errors) {
            deserialized.errors = json.errors;
        }

        if (json.links) {
            deserialized.links = json.links;
        }

        return deserialized;
    }
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)