serializeDataContainerToJSON
The serializeDataContainerToJSON function is used to serialize a SingleDataContainer or a MultiDataContainer.
Syntax
c4i:serializeDataContainerToJSON(xpath [, keyMetaAttribute] [, displayReferenceTarget] [, keysOrder] [, lov] [, units] [, values])
Parameters
xpath
XPath to a Data Container
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
displayReferenceTarget (optional)
- Indicates whether to display reference target ID or key value
- The authorized values are "BY_ID" (default) or "BY_KEY"
keysOrder (optional)
- Indicates the order in with the keys should be used when an object has multiple key values
- Separate keys using a comma (,). Example : "Key1,Key2"
lov (optional)
- Indicates how to represent LOV values
- The authorized values are "DISPLAY_LOV_VALUE_LABEL" (default), "DISPLAY_LOV_VALUE_ID" or "DISPLAY_BOTH"
units (optional)
- Indicates how to represent units
- The authorized values are "NO_UNITS" (default), "DISPLAY_UNIT_ID", "DISPLAY_UNIT_LABEL"
values (optional)
- Indicates if values and units should be concatenated or separated
- The authorized values are "CONCAT_VALUE_UNIT" (default) or "ISOLATE_VALUE"
Return value
A JSON document representing the Data Container, its 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"])
{
"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
}
}
]
}
}
}
Please refer to the documentation of multiValuesToJSON for more info on using the parameter values of this function.