Skip to content

objTo1d

Merges objects from the given object to the top level of the child items and displays the key names in steps, using a delimiter (. by default) instead of the existing keys. For example, if an object a has keys b, c, and d, the a key is not displayed, and the keys and values a.b, a.c, and a.d are displayed in the parent step.

Parameters

NameTypeRequiredDefault
objobject
separatornamedstring'.'

named parameters are passed as named parameters in Dart and keyword arguments in Python.

Returns

object

Examples

javascript
objTo1d({
	a: 1,
	b: {
		aa: 1,
		bb: 2
	},
	c: 3
});

/*
Returns:
{
	a: 1,
	'b.aa': 1,
	'b.bb': 2,
	c: 3
}
 */
dart
objTo1d({
  'a': 1,
  'b': {
    'aa': 1,
		'bb': 2
  },
  'c': 3
});

/*
Returns:
{
	'a': 1,
	'b.aa': 1,
	'b.bb': 2,
	'c': 3
}
 */
python
objTo1d({
	'a': 1,
	'b': {
		'aa': 1,
		'bb': 2
	},
	'c': 3
})

#
# Returns:
# {
# 	'a': 1,
# 	'b.aa': 1,
# 	'b.bb': 2,
# 	'c': 3
# }
#

Released under the MIT License