Take a json strust and a model name, and return a model instance
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)
867970
def from_json(cls, json):
        """"""
        obj = cls(name=json['name'],
                  code=json['code'],
                  numeric_code=json['numeric_code'],
                  symbol=json['symbol'],
                  exponent=json['exponent'],
                  entities=json['entities'],
                  withdrawal_date=json['withdrawal_date'],
                  subunits=json['subunits'])
        return obj
201850
def fromJSON(value):
        
        j = json.loads(value)
        v = GPFeatureRecordSetLayer()
        if "defaultValue" in j:
            v.value = j['defaultValue']
        else:
            v.value = j['value']
        if 'paramName' in j:
            v.paramName = j['paramName']
        elif 'name' in j:
            v.paramName = j['name']
        return v
947206
function (model) {

                var ret = [];

                function getSubModel(obj) {

                    if (obj === model) {
                        return;
                    }

                    if (_.indexOf(ret, obj) !== -1) {
                        // already in list
                        return;
                    }

                    if (obj instanceof Model) {
                        ret.push(obj);
                        return;
                    }

                    for (var key in obj) {
                        if (obj.hasOwnProperty(key)) {
                            var value = obj[key];

                            if (value instanceof Array) {
                                for (var i = 0; i < value.length; i++) {
                                    getSubModel(value[i]);
                                }
                            } else if (value instanceof List) {
                                value.each(getSubModel);
                            } else if (value instanceof Object) {
                                getSubModel(value);
                            }
                        }
                    }
                }

                getSubModel(model.$);

                return ret;

            }
1011039
function (req, res) {
        {modelName}.find(function (err, {pluralName}) {
            if (err) {
                return res.status(500).json({
                    message: 'Error when getting {name}.',
                    error: err
                });
            }
            return res.json({pluralName});
        });
    }
939631
def from_json(cls, data):
        
        user = cls()

        user.user_id = data['userId']
        user.username = data['username']
        user.auth_system = data['authSystem']
        user.roles = data['roles']

        return user
427632
def from_json(self, json):
        
        res_type = json['sys']['type']

        if ResourceType.Array.value == res_type:
            return self.create_array(json)
        elif ResourceType.Entry.value == res_type:
            return self.create_entry(json)
        elif ResourceType.Asset.value == res_type:
            return ResourceFactory.create_asset(json)
        elif ResourceType.ContentType.value == res_type:
            return ResourceFactory.create_content_type(json)
        elif ResourceType.Space.value == res_type:
            return ResourceFactory.create_space(json)
505927
def build_json_resource_obj(cls, fields, resource, resource_instance, resource_name,
                                force_type_resolution=False):
        
        # Determine type from the instance if the underlying model is polymorphic
        if force_type_resolution:
            resource_name = utils.get_resource_type_from_instance(resource_instance)
        resource_data = [
            ('type', resource_name),
            ('id', encoding.force_text(resource_instance.pk) if resource_instance else None),
            ('attributes', cls.extract_attributes(fields, resource)),
        ]
        relationships = cls.extract_relationships(fields, resource, resource_instance)
        if relationships:
            resource_data.append(('relationships', relationships))
        # Add 'self' link if field is present and valid
        if api_settings.URL_FIELD_NAME in resource and \
                isinstance(fields[api_settings.URL_FIELD_NAME], relations.RelatedField):
            resource_data.append(('links', {'self': resource[api_settings.URL_FIELD_NAME]}))
        return OrderedDict(resource_data)
1001568
def create_authentication_from_json(values):
        """"""
        key_id = values.get('publicKey')
        authentication_type = values.get('type')
        if not key_id:
            raise ValueError(
                f'Invalid authentication definition, "publicKey" is missing: {values}')

        authentication = {'type': authentication_type, 'publicKey': key_id}

        return authentication
694278
def from_json(cls, json_obj):
        
        return cls(json_obj["name"], lb=json_obj["lb"], ub=json_obj["ub"], type=json_obj["type"])
365537
def model_to_json(self, object, cleanup=True):
        """"""
        model_name = type(object).__name__
        if model_name not in self.swagger_dict['definitions']:
            raise ValidationError("Swagger spec has no definition for model %s" % model_name)
        model_def = self.swagger_dict['definitions'][model_name]
        log.debug("Marshalling %s into json" % model_name)
        m = marshal_model(self.spec, model_def, object)
        if cleanup:
            self.cleanup_model(m)
        return m
1064019
def _get_model_instance(model_cls, data):
        
        if not isinstance(data, (model_cls, dict)):
            raise TypeError('{0} is not valid type, instance of '
                            '{1} or dict required'.format(data, model_cls))
        return model_cls(**data) if isinstance(data, dict) else data
1131998
def instantiate_references_json(references_json):
    ''' 

    '''

    # Create all instances, but without setting their props
    references = {}
    for obj in references_json:
        obj_id = obj['id']
        obj_type = obj.get('subtype', obj['type'])

        cls = get_class(obj_type)
        instance = cls.__new__(cls, id=obj_id)
        if instance is None:
            raise RuntimeError('Error loading model from JSON (type: %s, id: %s)' % (obj_type, obj_id))
        references[instance.id] = instance

    return references
820910
def from_json(cls, json):
    """"""
    return cls(json[cls.BLOB_KEY_PARAM],
               json[cls.INITIAL_POSITION_PARAM],
               json[cls.END_POSITION_PARAM])
718591
def from_json(stream, cls=None, object_pairs_hook=OrderedDict, **extras):
    
    stream = stream.read() if hasattr(stream, 'read') else stream
    json_dict = json.loads(stream, object_pairs_hook=object_pairs_hook)
    if extras:
        json_dict.update(extras)  # pragma: no cover
    return to_model(cls, json_dict) if cls else json_dict
911025
def from_json(cls, obj):
        
        if len(obj) == 2:
            (field, operator) = obj
            return cls(field, operator)
        if len(obj) > 2:
            (field, operator, value) = obj
            return cls(field, operator, value)
481298
def json_to_model(self, model_name, j):
        """"""
        if model_name not in self.swagger_dict['definitions']:
            raise ValidationError("Swagger spec has no definition for model %s" % model_name)
        model_def = self.swagger_dict['definitions'][model_name]
        log.debug("Unmarshalling json into %s" % model_name)
        return unmarshal_model(self.spec, model_def, j)