serializeAttributeLinksToJSON
The serializeAttributeLinksToJSON
function is used to serialize the attribute links from an object to a JSON document.
Syntax
c4i:serializeAttributeLinksToJSON(xpath [, lov] [, units] [, values])
Parameters
xpath
XPath to the "AttributeLink" XML nodes.
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 containing the attribute links and associated metadata.
Example
Given the following STEP XML:
<STEP-ProductInformation ExportTime="2020-06-05 10:13:28" ContextID="FR" WorkspaceID="Main">
<AttributeList>
<Attribute ID="ATD_VARIANT_PRIORITY">
<Validation BaseType="integer"/>
</Attribute>
<Attribute ID="DefaultUnit">
<Validation BaseType="text"/>
</Attribute>
</AttributeList>
<Products>
<Product UserTypeID="PROD_ARTICLE" ID="PRD0001">
<AttributeLink AttributeID="ATT_001"/>
<AttributeLink AttributeID="ATT_002">
<MetaData>
<Value AttributeID="ATD_VARIANT_PRIORITY">2</Value>
</MetaData>
</AttributeLink>
<AttributeLink AttributeID="ATT_003">
<MetaData>
<Value AttributeID="ATD_VARIANT_PRIORITY">1</Value>
<Value AttributeID="DefaultUnit">units.cm2</Value>
</MetaData>
</AttributeLink>
<Name>Test Product</Name>
<Values/>
</Product>
</Products>
</STEP-ProductInformation>
The following YAML configuration will produce the following output :
c4i:serializeAttributeLinksToJSON(AttributeLink[MetaData/Value[@AttributeID="ATD_VARIANT_PRIORITY"]])
{
"attributeLinks": {
"ATT_002": {
"ATD_VARIANT_PRIORITY": 2
},
"ATT_003": {
"ATD_VARIANT_PRIORITY": 1,
"DefaultUnit": "units.cm2"
}
}
}
Please refer to the documentation of multiValuesToJSON
for more info on using the parameter values of this function.