ObjectPath Class
Helper methods for working with json objects.
Constructor
ObjectPath()
Methods
| assign |
Creates a new object by overlaying values in start_object with non-null values from overlay_object. |
| for_each_property | |
| get_path_value |
Get the value for a path relative to an object. |
| has_value |
Does an object have a subpath. |
| is_int | |
| remove_path_value |
Remove path from object. |
| set_path_value |
Given an object evaluate a path to set the value. |
| try_get_path_value |
Get the value for a path relative to an object. |
| try_resolve_path |
assign
Creates a new object by overlaying values in start_object with non-null values from overlay_object.
static assign(start_object, overlay_object, default: Callable | object = None)
Parameters
| Name | Description |
|---|---|
|
start_object
Required
|
dict or typed object, the target object to set values on |
|
overlay_object
Required
|
dict or typed object, the item to overlay values form |
|
default
|
Provides a default object if both source and overlay are None Default value: None
|
Returns
| Type | Description |
|---|---|
|
A copy of start_object, with values from overlay_object |
for_each_property
static for_each_property(obj: object, action: Callable[[str, object], None])
Parameters
| Name | Description |
|---|---|
|
obj
Required
|
|
|
action
Required
|
|
get_path_value
Get the value for a path relative to an object.
static get_path_value(obj, path: str, default: Callable | object = None) -> object
Parameters
| Name | Description |
|---|---|
|
obj
Required
|
|
|
path
Required
|
|
|
default
|
Default value: None
|
has_value
Does an object have a subpath.
static has_value(obj, path: str) -> bool
Parameters
| Name | Description |
|---|---|
|
obj
Required
|
|
|
path
Required
|
|
is_int
static is_int(value: str) -> bool
Parameters
| Name | Description |
|---|---|
|
value
Required
|
|
remove_path_value
Remove path from object.
static remove_path_value(obj, path: str)
Parameters
| Name | Description |
|---|---|
|
obj
Required
|
|
|
path
Required
|
|
set_path_value
Given an object evaluate a path to set the value.
static set_path_value(obj, path: str, value: object)
Parameters
| Name | Description |
|---|---|
|
obj
Required
|
|
|
path
Required
|
|
|
value
Required
|
|
try_get_path_value
Get the value for a path relative to an object.
static try_get_path_value(obj, path: str) -> object
Parameters
| Name | Description |
|---|---|
|
obj
Required
|
|
|
path
Required
|
|
try_resolve_path
static try_resolve_path(obj, property_path: str, evaluate: bool = False) -> []
Parameters
| Name | Description |
|---|---|
|
obj
Required
|
|
|
property_path
Required
|
|
|
evaluate
|
Default value: False
|