Converts a Hash of object data into a concrete SObject
5885
def record_from_hash(data)
      attributes = data.delete('attributes')
      new_record = find_or_materialize(attributes["type"]).new
      data.each do |name, value|
        field = new_record.description['fields'].find do |field|
          key_from_label(field["label"]) == name || field["name"] == name || field["relationshipName"] == name
        end

        # Field not found
        if field == nil
          break
        end

        # If reference/lookup field data was fetched, recursively build the child record and apply
        if value.is_a?(Hash) and field['type'] == 'reference' and field["relationshipName"]
          relation = record_from_hash( value )
          set_value( new_record, field["relationshipName"], relation, 'reference' )

        # Apply the raw value for all other field types
        else
          set_value(new_record, field["name"], value, field["type"]) if field
        end
      end
      new_record
    end
1044757
def _to_hash(value)
      if value.is_a?(Array)
        value.compact.map{ |v| _to_hash(v) }
      elsif value.is_a?(Hash)
        {}.tap do |hash|
          value.each { |k, v| hash[k] = _to_hash(v) }
        end
      elsif value.respond_to? :to_hash
        value.to_hash
      else
        value
      end
    end
1342537
def to_a
      hash = {}
      @to_a ||=
        elements_with_tags.map.with_index do |(el, tag_name), idx|
          selector = @selector.dup
          selector[:index] = idx unless idx.zero?
          element = element_class.new(@query_scope, selector)
          if [HTMLElement, Input].include? element.class
            construct_subtype(element, hash, tag_name).tap { |e| e.cache = el }
          else
            element.tap { |e| e.cache = el }
          end
        end
    end
25085
function objectToArray(o, order) {
    order = order || Object.keys(o);

    return order.map(function(k) {
      return o[k];
    });
  }
119259
def to_hash arr
      return {}   if arr.nil?
      return arr  if arr.kind_of?(Hash)
      arr = [ arr.to_sym ]  unless arr.kind_of?(Array)
      ret = {}
      arr.each { |key| ret[key.to_sym] = {} }
      ret
    end
1166757
def to_child_hash
      hash = {}
      children { |child| hash[child.name] = child.value }
      return hash
    end
1110012
function __serializeObject(data, options=DEFAULT_OPTIONS) {
	let dataBuffers = [];
	let allKeys = (options.sort_key === true) ? Object.keys(data).sort() : Object.keys(data);
	// ignore undefined value
	for (let key of allKeys) {
		let subData = data[key];
		if (subData === undefined) continue;

		let subType = __getType(subData, options);
		let subTypeBuffer = __serializeType(subType);
		let keyBuffers = __serializeShortString(key);
		let subDataBuffers = __serializeData(subType, subData, options);
		dataBuffers.push(subTypeBuffer, ...keyBuffers, ...subDataBuffers);
	}
	let length = __getLengthByArrayBuffers(dataBuffers);
	let lengthData = new Uint32Array([length]);
	return [lengthData.buffer, ...dataBuffers];
}
1103106
def stringify_keys(object)
      case object
      when Hash
        object.each_with_object({}) do |(key, value), result|
          result[key.to_s] = stringify_keys(value)
        end
      when Array
        object.map { |e| stringify_keys(e) }
      else
        object
      end
    end
1079151
def to_hash(val)
      if @options[:humidity] then
        return {"humidity" => val.humidity}
      end

      if @options[:unit] == :c then
        if @options[:temperature] then
          return {"temperature" => val.temp}
        else
          return {"temperature" => val.temp, "humidity" => val.humidity}
        end
      else
        if @options[:temperature] then
          return {"temperature" => val.temp_f}
        else
          return {"temperature" => val.temp_f, "humidity" => val.humidity}
        end
      end
    end
1077140
def object_to_items(data_structure):
    """"""
    items = []
    # Get all items from dict
    try:
        items = list(data_structure.__dict__.items())
    except:
        pass
    # Get all slots
    hierarchy = [data_structure]
    try:
        hierarchy += inspect.getmro(data_structure)
    except:
        pass
    slots = []
    try:
        for b in hierarchy:
            try:
                slots += b.__slots__
            except:  # pragma: no cover
                pass
    except:  # pragma: no cover
        pass
    # Get attrs from slots
    for x in slots:
        items.append((x, getattr(data_structure, x)))
    return items
968602
def to_hash
      result = { }

      # id
      result['_id'] = @_id if @_id

      # timestamp
      result['at'] = @at

      # kind
      result['kind'] = kind.to_s

      # entities
      @entities.each do |entity_name, entity|
        result[entity_name.to_s] = entity.model_id
      end

      # meta
      result['meta'] = @meta.stringify_keys unless @meta.blank?

      result
    end
1185670
function hash(object) {
    if (object === undefined || isScalar(object)) {
        return '' + object;
    }

    if (object.hash) {
        return object.hash();
    }

    //Default implementation
    var hashes = [],
        value, key, hashKey, hashValue;

    for (key in object) {
        if (object.hasOwnProperty(key)) {
            value = object[key];
            hashKey = String(key);
            hashValue = hash(value);
            hashValue = (hashKey > hashValue) ? hashValue + hashKey : hashKey + hashValue;
            hashes.push(hashValue);
        }
    }

    return hashes.sort().join('');
}
1168899
def to_params_hash(keys,values)
      hash = {}
      keys.size.times { |i| hash[ keys[i].to_sym ] = values[i] }
      hash
    end
789941
def to_hash
      result = {
        name: @name,
        value: @value,
        domain: @domain,
        path: @path,
        created_at: @created_at
      }
      {
        expiry: @expiry,
        secure: (true if @secure),
        http_only: (true if @http_only),
        version: (@version if version != 0),
        comment: @comment,
        comment_url: @comment_url,
        discard: (true if @discard),
        ports: @ports
      }.each do |name, value|
        result[name] = value if value
      end

      result
    end
520228
def to_s
      hash = {}
      @hooks_map.each_pair do |hook_event, nested_hash|
        hash[hook_event] = {}
        nested_hash.each_pair do |name, callbacks|
          hash[hook_event][name] = callbacks
        end
      end
      hash.to_s
    end
1357122
function hash() {
	var i = 0,
		args = arguments,
		length = args.length,
		obj = {};
	for (; i < length; i++) {
		obj[args[i++]] = args[i];
	}
	return obj;
}
586656
def _object_reducer(o, names=('id', 'name', 'path', 'httpMethod',
                              'statusCode', 'Created', 'Deleted',
                              'Updated', 'Flushed', 'Associated', 'Disassociated')):
    '''
    
    '''
    result = {}
    if isinstance(o, dict):
        for k, v in six.iteritems(o):
            if isinstance(v, dict):
                reduced = v if k == 'variables' else _object_reducer(v, names)
                if reduced or _name_matches(k, names):
                    result[k] = reduced
            elif isinstance(v, list):
                newlist = []
                for val in v:
                    reduced = _object_reducer(val, names)
                    if reduced or _name_matches(k, names):
                        newlist.append(reduced)
                if newlist:
                    result[k] = newlist
            else:
                if _name_matches(k, names):
                    result[k] = v
    return result