module documentation
This module provides various JSON/Dictionary utility functions.
| Function | pure |
Return the "pure" structure without the "<domain>:xxx" resource type name, and the oneM2M type identifier. |
| Function | resource |
Compare an old and a new resource. A comparison happens for keywords and values. Attributes which names start and end with "__" (ie internal attributes) are ignored. |
| Function | resource |
Calculate the difference between an original resource and after it has been updated, and then remove the attributes that are part of the update request. |
| Variable | _exclude |
Attributes that are excluded from the root of a resource tree. |
| Variable | _pure |
Regular expression to test for a pure resource name. |
Return the "pure" structure without the "<domain>:xxx" resource type name, and the oneM2M type identifier.
| Parameters | |
dct:JSON | JSON dictionary with the resource attributes. |
| Returns | |
tuple[ | Tupple with the inner JSON, the resource type name, and the found key. If the resource type name is not in the correct format, eg the domain is missing, it is None. The third element always contains the found outer attribute name. |
Compare an old and a new resource. A comparison happens for keywords and values. Attributes which names start and end with "__" (ie internal attributes) are ignored.
| Parameters | |
old:JSON | Old resource dictionary to compare. |
new:JSON | New resource dictionary to compare. |
modifiers:JSON | None | A dictionary. If this dictionary is given then it contains the changes that let from old to new. This is used to determine if attributes were just updated with the same values. |
| Returns | |
JSON | Return a dictionary of identified changes. |
def resourceModifiedAttributes(old:
JSON, new: JSON, requestPC: JSON, modifiers: JSON | None = None) -> JSON:
¶
Calculate the difference between an original resource and after it has been updated, and then remove the attributes that are part of the update request.
| Parameters | |
old:JSON | Old resource dictionary to compare. |
new:JSON | New resource dictionary to compare. |
requestJSON | The original request's content. This is used to remove the attributes that are part of the update request. |
modifiers:JSON | None | A dictionary. If this dictionary is given then it contains the changes that let from old to new. This is used to determine if attributes were just updated with the same values. |
| Returns | |
JSON | Return a dictionary of those attributes that have been changed in a CREATE or UPDATE request. |