pip_services3_commons.convert.MapConverter module
pip_services3_commons.convert.MapConverter
Map conversion utilities
- copyright
Conceptual Vision Consulting LLC 2018-2019, see AUTHORS for more details.
- license
MIT, see LICENSE for more details.
-
class
pip_services3_commons.convert.MapConverter.
MapConverter
Bases:
object
Converts arbitrary values into map objects using extended conversion __rules: - Objects: property names as keys, property values as values - Arrays: element indexes as keys, elements as values
Example:
value1 = MapConverter.to_nullable_map("ABC") // Result: None value2 = MapConverter.to_nullable_map({ key: 123 }) // Result: { key: 123 } value3 = MapConverter.to_nullable_map([1,2,3]) // Result: { "0": 1, "1": 2, "2": 3 }
-
static
to_map
(value: Any) → Any Converts args into map object or returns empty map when conversion is not possible
- Parameters
value – the args to convert.
- Returns
map object or empty map when conversion is not supported.
-
static
to_map_with_default
(value: Any, default_value: Any) → Any Converts args into map object or returns default when conversion is not possible
- Parameters
value – the args to convert.
default_value – the default args.
- Returns
map object or emptu map when conversion is not supported.
-
static
to_nullable_map
(value: Any) → Any Converts args into map object or returns null when conversion is not possible.
- Parameters
value – the args to convert.
- Returns
map object or null when conversion is not supported.
-
static