CompanionCompanion
Companion for Delivery
Companion for Business
Companion for Integration
Contact us
Log out
Companion for Delivery
Companion for Business
Companion for Integration
Contact us
  • Companion for Integration

    • Introduction
    • Getting Started
    • Configuration
    • Excel templating
    • How it works
  • YAML Configuration

    • Principles
    • Syntax
    • Validation
  • Custom Functions

    • Summary
    • arrayToJSON
    • bool
    • concatValueAndUnit
    • convertUnit
    • currentContextId
    • exportTime
    • eval
    • firstNonEmpty
    • getContextName
    • getEvents
    • getLastEventTime
    • getReferencesByAttributeGroup
    • getStoredValue
    • getWorkspaceId
    • hash
    • hasStoreKey
    • if
    • integer
    • join
    • mergeInheritedValues
    • multiValuesToJSON
    • number
    • nodeList
    • order
    • resolveUnitLabel
    • serializeAssetPushLocationsToJSON
    • serializeAttributeLinksToJSON
    • serializeContextReferenceToJSON
    • serializeContextReferencesToJSON
    • serializeContextValuesToJSON
    • serializeDataContainerToJSON
    • serializeDataContainersToJSON
    • serializeListOfValueValuesToJSON
    • serializeReferencesToJSON
    • serializeReferenceToJSON
    • serializeValuesToJSON
    • store
    • toXML
    • uppercase
  • Execution

    • Summary
    • Composite
    • From STEP
    • Standalone
    • Performance statistics
  • Configuration

    • ActiveMQ extension
    • Amazon AWS extension (SNS, SQS, Kinesis, S3)
    • ElasticSearch/OpenSearch extension
    • File extension (Excel, CSV, JSON, XML, JSONL, XMLL)
    • Kafka extension
    • Kafka Core extension
    • MongoDB/Cosmos DB extension
    • SQL extension
    • REST extension
    • Google Pub/Sub extension
  • c4i SaaS

    • Introduction
    • Managing jobs
    • Managing executions
    • Managing users
    • Changelog
  • Changelog

    • Core features changelog
    • ActiveMQ extension changelog
    • Amazon AWS extension changelog
    • Composite extension changelog
    • ElasticSearch extension changelog
    • File extension changelog
    • Kafka extension changelog
    • Kafka Core extension changelog
    • MongoDB/Cosmos DB extension changelog
    • SQL extension changelog
    • REST extension changelog
    • Google Pub/Sub extension changelog

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.

Last Updated: 6/26/24, 10:06 AM
Prev
serializeAssetPushLocationsToJSON
Next
serializeContextReferenceToJSON