JSON Ops
And
Bases: Operation
Perform a logical And
operation between data models.
Source code in synalinks/src/ops/json.py
Concat
Bases: Operation
Concatenate two data models together.
Source code in synalinks/src/ops/json.py
Factorize
Bases: Operation
Factorize a data model by grouping similar properties together.
Source code in synalinks/src/ops/json.py
InMask
Bases: Operation
Keep specific fields of a data model.
Source code in synalinks/src/ops/json.py
Or
Bases: Operation
Perform a logical Or
operation between data models.
Source code in synalinks/src/ops/json.py
OutMask
Bases: Operation
Mask specific fields of a data model.
Source code in synalinks/src/ops/json.py
Prefix
Bases: Operation
Add a prefix to all the data model fields (non-recursive).
Source code in synalinks/src/ops/json.py
Suffix
Bases: Operation
Add a suffix to all the data model fields (non-recursive).
Source code in synalinks/src/ops/json.py
concat(x1, x2, name=None, description=None)
async
Concatenate two data models together.
Concatenation consist in creating a new data model containing
all the elements of the two inputs into a new one.
Each field name is made unique if needed by adding a numerical suffix _n
,
with n
being an incremental integer.
This operation is implemented in the +
Python operator.
If any of the data models used is a metaclass or symbolic data model the output is a symbolic data model.
If any of the inputs is None, then an exception is raised.
If the keys are used more than once, a numerical suffix is added.
Table:
x1 |
x2 |
Concat (+ ) |
---|---|---|
x1 |
x2 |
x1 + x2 |
x1 |
None |
Exception |
None |
x2 |
Exception |
None |
None |
Exception |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x1
|
JsonDataModel | SymbolicDataModel
|
the first input data model. |
required |
x2
|
JsonDataModel | SymbolicDataModel
|
the second input data model. |
required |
name
|
str
|
Optional. The name of the operation. |
None
|
description
|
str
|
Optional. The description of the operation. |
None
|
Returns:
Type | Description |
---|---|
JsonDataModel | SymbolicDataModel
|
The resulting data model |
Source code in synalinks/src/ops/json.py
factorize(x, name=None, description=None)
async
Factorize a data model by grouping similar properties together.
Factorization consist in grouping the same properties into lists.
The property key of the resulting grouped property is changed to its plural form.
For example action
become actions
, or query
become queries
.
If the data models used is a metaclass or symbolic data model the output is a symbolic data model.
This operation is implemented in .factorize()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
JsonDataModel | SymbolicDataModel
|
the input data model. |
required |
name
|
str
|
Optional. The name of the operation. |
None
|
description
|
str
|
Optional. The description of the operation. |
None
|
Returns:
Type | Description |
---|---|
JsonDataModel | SymbolicDataModel
|
The resulting data model. |
Source code in synalinks/src/ops/json.py
in_mask(x, mask=None, recursive=True, name=None, description=None)
async
Keep specific fields of a data model.
In masking consists in keeping the properties that match with the keys given in the mask. The masking process ignores the numerical suffixes that could be added by other operations.
If the data models used is a metaclass or symbolic data model the output is a symbolic data model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
JsonDataModel | SymbolicDataModel
|
the input data model |
required |
mask
|
list
|
the input mask (list of keys) |
None
|
recursive
|
bool
|
Whether or not to keep recursively for nested objects (default True). |
True
|
name
|
str
|
Optional. The name of the operation. |
None
|
description
|
str
|
Optional. The description of the operation. |
None
|
Returns:
Type | Description |
---|---|
JsonDataModel | SymbolicDataModel
|
The resulting data model. |
Source code in synalinks/src/ops/json.py
logical_and(x1, x2, name=None, description=None)
async
Perform a logical And
operation between two data models.
If one of the inputs is None
, then this operation output None
.
If both inputs are provided, the output is a concatenation
of the two given data models.
This operation is implemented in the Python &
operator.
If any of the data models used is a metaclass or symbolic data model the output is a symbolic data model.
Table:
x1 |
x2 |
Logical And (& ) |
---|---|---|
x1 |
x2 |
x1 + x2 |
x1 |
None |
None |
None |
x2 |
None |
None |
None |
None |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x1
|
JsonDataModel | SymbolicDataModel
|
The first input data model. |
required |
x2
|
JsonDataModel | SymbolicDataModel
|
The second input data model. |
required |
name
|
str
|
Optional. The name of the operation. |
None
|
description
|
str
|
Optional. The description of the operation. |
None
|
Returns:
Type | Description |
---|---|
JsonDataModel | SymbolicDataModel | None
|
The resulting data model or None if the condition is not met. |
Source code in synalinks/src/ops/json.py
logical_or(x1, x2, name=None, description=None)
async
Perform a logical Or
between two data models.
If one of the input is None
, then output the other one.
If both inputs are provided, the output is a concatenation
of the two given data models.
If any of the data models used is a metaclass or symbolic data model the output is a symbolic data model.
This operation is implemented in the Python |
operator.
Table:
x1 |
x2 |
Logical Or (| ) |
---|---|---|
x1 |
x2 |
x1 + x2 |
x1 |
None |
x1 |
None |
x2 |
x2 |
None |
None |
None |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x1
|
JsonDataModel | SymbolicDataModel
|
The first input data model. |
required |
x2
|
JsonDataModel | SymbolicDataModel
|
The second input data model. |
required |
name
|
str
|
Optional. The name of the operation. |
None
|
description
|
str
|
Optional. The description of the operation. |
None
|
Returns:
Type | Description |
---|---|
JsonDataModel | SymbolicDataModel | None
|
The resulting data model or None if the condition is not met. |
Source code in synalinks/src/ops/json.py
out_mask(x, mask=None, recursive=True, name=None, description=None)
async
Mask specific fields of a data model.
Out masking consist in removing the properties that match with the keys given in the mask. The masking process ignore the numerical suffixes that could be added by other operations.
If the data models used is a metaclass or symbolic data model the output is a symbolic data model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
JsonDataModel | SymbolicDataModel
|
the input data model. |
required |
mask
|
list
|
the input mask (list of keys). |
None
|
recursive
|
bool
|
Whether or not to remove recursively for nested objects (default True). |
True
|
name
|
str
|
Optional. The name of the operation. |
None
|
description
|
str
|
Optional. The description of the operation. |
None
|
Returns:
Type | Description |
---|---|
JsonDataModel | SymbolicDataModel
|
The resulting data model. |
Source code in synalinks/src/ops/json.py
prefix(x, prefix=None, name=None, description=None)
async
Add a prefix to all the data model fields (non-recursive).
If the data models used is a metaclass or symbolic data model the output is a symbolic data model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
JsonDataModel | SymbolicDataModel
|
the input data model |
required |
prefix
|
str
|
the prefix to add. |
None
|
name
|
str
|
Optional. The name of the operation. |
None
|
description
|
str
|
Optional. The description of the operation. |
None
|
Returns:
Type | Description |
---|---|
JsonDataModel | SymbolicDataModel
|
The resulting data model. |
Source code in synalinks/src/ops/json.py
suffix(x, suffix=None, name=None, description=None)
async
Add a suffix to all the data model fields (non-recursive).
If the data models used is a metaclass or symbolic data model the output is a symbolic data model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
JsonDataModel | SymbolicDataModel
|
the input data model |
required |
suffix
|
str
|
the suffix to add. |
None
|
name
|
str
|
Optional. The name of the operation. |
None
|
description
|
str
|
Optional. The description of the operation. |
None
|
Returns:
Type | Description |
---|---|
JsonDataModel | SymbolicDataModel
|
The resulting data model |