Populates a given objects attributes from a parsed JSON API response.
        This helper handles all necessary type coercions as it assigns
        attribute values.
434692
def from_response(self, response):
        
        for name in self.PROPERTIES:
            attr = '_{0}'.format(name)
            transform = self.PROPERTIES[name].get('transform', None)
            value = response.get(name, None)
            if transform and transform == TRANSFORM.TIME and value:
                setattr(self, attr, dateutil.parser.parse(value))
            if isinstance(value, int) and value == 0:
                continue  # skip attribute
            else:
                setattr(self, attr, value)

        return self
969784
def populate
      file = File.read(json_file)
      storage = JSON.parse(file, :symbolize_names => true)

      @hashes = storage[:hashes]
      convert if @hashes.is_a? Array

      @hashes
    end
410639
def from_api(cls, api, **kwargs):
        
        if not cls._api_attrs:
            raise NotImplementedError()

        def resolve_attribute_type(attr_type):
            # resolve arrays of types down to base type
            while isinstance(attr_type, list):
                attr_type = attr_type[0]
            # attribute type 'self' resolves to current class
            if attr_type == 'self':
                attr_type = cls
            # attribute type 'date' is a unix timestamp
            if attr_type == 'date':
                attr_type = datetime.datetime.fromtimestamp
            # string attributes should use unicode literals
            if attr_type is str:
                attr_type = unicode
            # if attribute type is an APIObject, use the from_api factory method and pass the `api` argument
            if hasattr(attr_type, 'from_api'):
                return lambda **kw: attr_type.from_api(api, **kw)
            return attr_type

        def instantiate_attr(attr_value, attr_type):
            if isinstance(attr_value, dict):
                return attr_type(**attr_value)
            return attr_type(attr_value)

        def instantiate_array(attr_values, attr_type):
            func = instantiate_attr
            if isinstance(attr_values[0], list):
                func = instantiate_array
            return [func(val, attr_type) for val in attr_values]

        def instantiate(attr_value, attr_type):
            if isinstance(attr_value, list):
                return instantiate_array(attr_value, attr_type)
            return instantiate_attr(attr_value, attr_type)

        instance = cls(api)
        for attr_name, attr_type, attr_default in cls._api_attrs:
            # grab the current attribute value
            attr_value = kwargs.get(attr_name, attr_default)
            # default of TypeError means a required attribute, raise Exception
            if attr_value is TypeError:
                raise TypeError('{} requires argument {}'.format(cls.__name__, attr_name))
            attr_type = resolve_attribute_type(attr_type)
            # if value has been provided from API, instantiate it using `attr_type`
            if attr_value != attr_default:
                attr_value = instantiate(attr_value, attr_type)
            # rename the 'from' variable, reserved word
            if attr_name == 'from':
                attr_name = 'froom'
            # and finally set the attribute value on the instance
            setattr(instance, attr_name, attr_value)
        return instance
357435
final public function populateByRequest() {

		$args = func_get_args();

		// all subclass binds
		$binds = static::getBinds();

		foreach ($binds as $property => $field) {

			// check that property is in the args or that args is not defined at all
			if (!count($args) or (isset($args[0]) and in_array($property, $args[0]))) {
				
				$type = $this->getPropertyType($property);
				
				if (Input::isSent($property) or 'bool' == $type) {
					
					// assign the value to this object property
					$this->__set($property, Input::get($property));
					
				}

			}

		}

	}
444350
def json_loads(cls, s, **kwargs):
        
        if 'cls' not in kwargs:
            kwargs['cls'] = cls.json_decoder
        return json.loads(s, **kwargs)
1267415
def to_instance(self, response):
        
        klass = self.schema['title']
        cls = get_model_class(klass, api=self.__api__)
        jdict = json.loads(response.content, encoding="utf-8")
        ### check if we have a response
        properties_dict = jdict[self.schema['title']]
        # @todo: find a way to handle the data
        # validation fails if the none values are not removed
        new_dict = helpers.remove_properties_containing_None(properties_dict)
        #jdict[self.schema['title']] = new_dict
        obj = cls(new_dict)
        #obj.links = jdict[self.schema['title']]['links']
        return obj
694278
def from_json(cls, json_obj):
        
        return cls(json_obj["name"], lb=json_obj["lb"], ub=json_obj["ub"], type=json_obj["type"])
862104
def create_attributes(klass, attributes, previous_object=None):
        

        if 'fields' not in attributes:
            if previous_object is None:
                attributes['fields'] = {}
            else:
                attributes['fields'] = previous_object.to_json()['fields']
        return {'fields': attributes['fields']}
160391
def populate_attributes
      self.class.normal_attribute_list.each do |normal_attribute|
        self.public_send "#{normal_attribute}=", raw_data[normal_attribute]
      end

      self.class.time_attribute_list.each do |time_attribute|
        time = raw_data[time_attribute]
        time = Time.parse(time) if !time.nil?
        self.public_send "#{time_attribute}=", time
      end

      self.class.collection_attribute_mappings.each do |collection_attribute, klass|
        collection = raw_data[collection_attribute] || []
        collection = {'data' => collection}
        collection = klass.response_collection(collection)
        self.public_send "#{collection_attribute}=", collection
      end
    end
152461
def _to_api_value(self, attribute_type, value):
        """"""

        if not value:
            return None

        if isinstance(attribute_type, properties.Instance):
            return value.to_api()

        if isinstance(attribute_type, properties.List):
            return self._parse_api_value_list(value)

        return attribute_type.serialize(value)
659279
def from_json(cls, data, json_schema_class=None):
        
        schema = cls.json_schema if json_schema_class is None else json_schema_class()
        return schema.load(data)
537433
def initialize_from_response_data # :nodoc:
        run_callbacks :initialize_from_response_data do
          self.class.attribute_options_including_superclasses.each do |name, options|
            value = if options[:type] == :key
              self[name].blank? ? options[:default] : self[name]
            elsif options[:type] == :one
              hash = self[name.to_s]
              hash && hash['@type'] ? self.class.new_from_response_data(hash) : nil
            elsif options[:type] == :many
              response_data[name] && response_data[name].map{|hash| self.class.new_from_response_data(hash)} || []
            else
              raise "Invalid type: #{options[:type]}"
            end

            send("#{name}=", value)
          end
        end
      end
378323
def _from_json(cls, response_raw, wrapper=None):
        

        json = response_raw.body_bytes.decode()
        obj = converter.json_to_class(dict, json)
        value = converter.deserialize(
            cls,
            cls._unwrap_response_single(obj, wrapper)
        )

        return client.BunqResponse(value, response_raw.headers)
763504
def update_attrs(self):
        
        for key, value in self._response_json.items():
            if key != 'results' and type(value) not in (list, dict):
                setattr(self, key, value)
1028561
def from_json(cls, attributes):
        
        return cls(**{to_snake_case(k): v for k, v in attributes.items()})
432296
def object_from_json(self, object_type, object_json, parent=None):
        
        if not isinstance(object_json, dict):
            return object_json
        obj = self.instantiate_object(object_type, parent)
        for key, value in object_json.items():
            if key not in self.skip_attrs:
                key, value = self._deserialize(key, obj, value)
            if isinstance(value, dict):
                value = ProxyDict(value, dirty_callback=getattr(
                    obj, '_dirty_callback', None))
            elif isinstance(value, list):
                value = ProxyList(value, dirty_callback=getattr(
                    obj, '_dirty_callback', None))
            setattr(obj, key, value)
        if hasattr(obj, '_clean_dirty'):
            obj._clean_dirty()
        self.api.cache.add(obj)
        return obj
1007225
def _set_fields(self, json_dict):
        
        for key, value in json_dict.items():
            if not key.startswith("_"):
                setattr(self, key, value)