serializeDataContainersToJSON
The serializeDataContainersToJSON
function is used to serialize all the Data Containers from a Product or an Entity.
Syntax
c4i:serializeDataContainersToJSON(xpath [, keyMetaAttribute])
Parameters
xpath
XPath to a product or an entity. If the product/entity is the currently mapped object, just use ".".
keyMetaAttribute (optional)
- By default, attributes are indexed using their attribute ID
- If this parameter is supplied, attributes will be indexed using a meta-attribute value, if it is present
Return value
A JSON document representing the Data Containers, attributes and references
Example
Given the following STEP XML,
<STEP-ProductInformation>
<Products>
<Product ID="PRD1" UserTypeID="PRODUCT">
<Name>Test Product</Name>
<DataContainers>
<MultiDataContainer Type="DC_ETIM_VALUE_MULTIPLE">
<DataContainer ID="1408679">
<Values>
<Value AttributeID="ATD_ETIM_VALEUR">30</Value>
<Value AttributeID="ATD_ETIM_CLASSIFICATION">EC001582</Value>
<Value AttributeID="ATD_ETIM_CARACTERISTIQUE">EF006582</Value>
<Value AttributeID="ATD_ETIM_VERSION">7</Value>
</Values>
</DataContainer>
<DataContainer ID="1408680">
<Values>
<Value AttributeID="ATD_ETIM_VALEUR">60</Value>
<Value AttributeID="ATD_ETIM_CLASSIFICATION">EC001582</Value>
<Value AttributeID="ATD_ETIM_CARACTERISTIQUE">EF006582</Value>
<Value AttributeID="ATD_ETIM_VERSION">7</Value>
</Values>
</DataContainer>
</MultiDataContainer>
<SingleDataContainer ID="1508680" Type="DC_ETIM_VALUE_SINGLE">
<Values>
<Value AttributeID="ATD_ETIM_VALEUR">90</Value>
<Value AttributeID="ATD_ETIM_CLASSIFICATION">EC001582</Value>
<Value AttributeID="ATD_ETIM_CARACTERISTIQUE">EF006582</Value>
<Value AttributeID="ATD_ETIM_VERSION">7</Value>
</Values>
<ProductCrossReference Type="CrossSelling" ProductID="Target1"/>
<ProductCrossReference Type="Accessory" ProductID="Accessory1">
<MetaData>
<Value AttributeID="ATT_001">Test Value 1</Value>
<Value AttributeID="ATT_002">2020-04-02</Value>
<MultiValue AttributeID="ATT_003">
<Value>MultiValue1</Value>
<Value>MultiValue2</Value>
</MultiValue>
<Value AttributeID="ATT_004">16</Value>
</MetaData>
</ProductCrossReference>
<ProductCrossReference Type="CrossSelling" ProductID="Target2"/>
</SingleDataContainer>
</DataContainers>
</Product>
</Products>
</STEP-ProductInformation>
The following YAML configuration will produce the following output :
c4i:serializeDataContainerToJSON(DataContainers/SingleDataContainer[@Type="DC_ETIM_VALUE_SINGLE"))
{
"DC_ETIM_VALUE_SINGLE": {
"ID": "1508680",
"Type": "DC_ETIM_VALUE_SINGLE",
"Values": {
"ATD_ETIM_VALEUR": "90",
"ATD_ETIM_CLASSIFICATION": "EC001582",
"ATD_ETIM_CARACTERISTIQUE": "EF006582",
"ATD_ETIM_VERSION": "7"
},
"References": {
"ProductCrossReference": {
"CrossSelling": [
{
"target": "Target1"
},
{
"target": "Target2"
}
],
"Accessory": [
{
"target": "Accessory1",
"metaData": {
"ATT_001": "Test Value 1",
"ATT_002": "2020-04-02",
"ATT_003": [
"MultiValue1",
"MultiValue2"
],
"ATT_004": 16.0
}
}
]
}
}
},
"DC_ETIM_VALUE_MULTIPLE": [
{
"ID": "1408679",
"Type": "DC_ETIM_VALUE_MULTIPLE",
"Values": {
"ATD_ETIM_VALEUR": "30",
"ATD_ETIM_CLASSIFICATION": "EC001582",
"ATD_ETIM_CARACTERISTIQUE": "EF006582",
"ATD_ETIM_VERSION": "7"
}
},
{
"ID": "1408680",
"Type": "DC_ETIM_VALUE_MULTIPLE",
"Values": {
"ATD_ETIM_VALEUR": "60",
"ATD_ETIM_CLASSIFICATION": "EC001582",
"ATD_ETIM_CARACTERISTIQUE": "EF006582",
"ATD_ETIM_VERSION": "7"
}
}
]
}