Flattens a Map<String,Object> into a collection of attributes. This allows objects which have
already been parsed from json strings and processed to be turned into attribute stores as well.
338976
public static Collection<Attribute> fromMap(Map<String,Object> map) {
        requireNonNull(map);
        Collection<Attribute> attributes = new HashSet<>();
        convertObject(attributes, map, "", 0, new HashMap<>());
        return attributes;
    }
1275218
private static Map<String, Set<String>> flatten(Map<String, Set<String>> data) {
    Map<String, Set<String>> territories = new TreeMap<>();
    Set<String> keys = data.keySet();
    for (String key : keys) {
      Set<String> values = flatten(key, territories, data);
      territories.put(key, values);
    }
    return territories;
  }
543608
function flatten( a ) {
    var results;
    var isArray = ( a.length !== undefined && typeof a !== "string" );
    if ( isArray ) {
        results = []
        for ( var i = 0; i < a.length; i++ ) {
            var result = flatten( a[i] );
            results = results.concat( result );
        }
    } else {
        results = [ a ];
    }
    return results;
}
979009
private static Map<String, String> getAttributeMap(String source) {

		if (!StringUtils.hasText(source)) {
			return Collections.emptyMap();
		}

		Map<String, String> attributes = new HashMap<>();
		Matcher matcher = KEY_AND_VALUE_PATTERN.matcher(source);

		while (matcher.find()) {
			attributes.put(matcher.group(1), matcher.group(2));
		}

		return attributes;
	}
1261307
private static Map<String, Object> toMap(ObjectMapper objectMapper, JsonNode object) {
        return objectMapper.convertValue(object, new TypeReference<Map<String, Object>>() {
        });
    }
558419
function flatten(data, pre) {
  const prefix = pre || '';
  const keys = Object.keys(data);
  const result = {};
  keys.forEach((k) => {
    const value = data[k];
    const key = [prefix, k].join('-');
    if (isObject(value)) {
      Object.assign(result, flatten(value, key));
    } else {
      result[key] = value;
    }
  });
  return result;
}
407110
def flatatt(attrs):
    
    return _flatatt({k.replace('_', '-'): v for k, v in attrs.items()})
398918
protected Map<String, List<Object>> buildMutableAttributeMap(final Map<String, List<Object>> attributes) {
        final Map<String, List<Object>> mutableValuesBuilder = this.createMutableAttributeMap(attributes.size());

        for (final Map.Entry<String, List<Object>> attrEntry : attributes.entrySet()) {
            final String key = attrEntry.getKey();
            List<Object> value = attrEntry.getValue();

            if (value != null) {
                value = new ArrayList<>(value);
            }

            mutableValuesBuilder.put(key, value);
        }

        return mutableValuesBuilder;
    }
700963
def fromGeoJson(struct, attributes=None):
    ""
    if isinstance(struct, basestring):
        struct = json.loads(struct)
    type_map = {
        'Point': Point,
        'MultiLineString': Polyline,
        'LineString': Polyline,
        'Polygon': Polygon,
        'MultiPolygon': Polygon,
        'MultiPoint': Multipoint,
        'Box': Envelope
    }
    if struct['type'] == "Feature":
        return fromGeoJson(struct, struct.get('properties', None))
    elif struct['type'] == "FeatureCollection":
        sr = None
        if 'crs' in struct:
            sr = SpatialReference(struct['crs']['properties']['code'])
            members = map(fromGeoJson, struct['members'])
            for member in members:
                member.spatialReference = sr
            return members
        else:
            return map(fromGeoJson, struct['members'])
    elif struct['type'] in type_map and hasattr(type_map[struct['type']], 
                                              'fromGeoJson'):
        instances = type_map[struct['type']].fromGeoJson(struct)
        i = []
        assert instances is not None, "GeoJson conversion returned a Null geom"
        for instance in instances:
            if 'properties' in struct:
                instance.attributes = struct['properties'].copy()
                if '@esri.sr' in instance.attributes:
                    instance.spatialReference = SpatialReference.fromJson(
                                               instance.attributes['@esri.sr'])
                    del instance.attributes['@esri.sr']
            if attributes:
                if not hasattr(instance, 'attributes'):
                    instance.attributes = {}
                for k, v in attributes.iteritems():
                    instance.attributes[k] = v
            i.append(instance)
        if i:
            if len(i) > 1:
                return i
            return i[0]
    raise ValueError("Unconvertible to geometry")
3418
function(map, attr, val) {
	var serializer = attr === "*" ? false : getPropDefineBehavior("serialize", attr, map.define);
	if (serializer === undefined) {
		return oldSingleSerialize.call(map, attr, val);
	} else if (serializer !== false) {
		return typeof serializer === "function" ? serializer.call(map, val, attr) : oldSingleSerialize.call(map, attr, val);
	}
}
659570
function flatten(obj,callback) {
    let arr = [];
    let iDepth, oDepth = 0;
    let state = {identityDetection:true};
    recurse(obj,state,function(obj,key,state){
        let entry = {};
        entry.name = key;
        entry.value = obj[key];
        entry.path = state.path;
        entry.parent = obj;
        entry.key = key;
        if (callback) entry = callback(entry);
        if (entry) {
            if (state.depth > iDepth) {
                oDepth++;
            }
            else if (state.depth < iDepth) {
                oDepth--;
            }
            entry.depth = oDepth;
            iDepth = state.depth;
            arr.push(entry);
        }
    });
    return arr;
}
414317
private static String serializeVariantSets(Map<String, VariantSet> map) {
		StringBuilder result = new StringBuilder();

		for (Entry<String, VariantSet> entry : map.entrySet()) {
			result.append(entry.getKey()).append(":");
			VariantSet variantSet = (VariantSet) entry.getValue();
			result.append(variantSet.getDefaultVariant()).append(":");
			result.append(getCommaSeparatedString(variantSet));
			result.append(";");
		}

		return result.toString();
	}
807811
def parse_map(self, obj, mapping=None, *args, **kwargs):
        
        mapping = mapping or obj._mapping

        if "data" in kwargs:
            for k, v in mapping.items():
                if kwargs["data"].get(v, None) is not None:
                    val = kwargs["data"][v]
                else:
                    val = None
                self.add_attr(obj, k, val, from_json=True)
        else:
            for k, v in mapping.items():
                if k in kwargs:
                    self.add_attr(obj, k, kwargs[k])
217322
def flatten_json(data, prefix = None):
    '''
    
    '''
    # iterate all items
    for item in data:
        # split the object
        flat, key, subs = split_obj(item, prefix)

        # just return fully flat objects
        if key is None:
            yield flat
            continue

        # otherwise recursively flatten the subobjects
        for sub in flatten_json(subs, key):
            sub.update(flat)
            yield sub
214994
def from_maps(*maps):
        
        result = StringValueMap()
        
        if maps == None or len(maps) == 0:
            return result

        for map in maps:
            for (k, v) in map.items():
                key = StringConverter.to_string(k)
                result.put(key, v)

        return result
84075
function flatten(level, map) {
  for (var key in map) {
    var kmap = map[key];
    // we found a definition
    if (kmap._VAL_ || kmap._TAG_) {
      if (kmap._VAL_) {
        flatFields[key] = { level: level, _VAL_ : kmap._VAL_};
      } else {
        flatFields[key] = { level: level, _TAG_ : kmap._TAG_};
      }
    // presumed a level def
    } else {
      var here = level.slice(0);
      here.push(key);
      flatten(here, kmap);
    }
  }
}
704263
private void mapAttributes(List<Attribute> input, Map<String, List<Attribute>> output) {
        Iterator<Attribute> it = input.iterator();
        while (it.hasNext()) {
            Attribute attr = it.next();
            String id = attr.getId().toString();

            if (output.containsKey(id)) {
                List<Attribute> list = output.get(id);
                list.add(attr);
            } else {
                List list = new ArrayList<Attribute>();
                list.add(attr);
                output.put(id, list);
            }
        }
    }