This scenario provides a reversal of the previous example. The source stores the following information:

mail: jsmith@example.com

but the destination stores the following information:

ubidEmailJSON: {"value" : "jsmith@example.com"}

To construct an attribute value that functions as a JSON object, use JSON attribute mapping and JSON attribute mapping field configuration objects. The following code provides an example:

bin/dsconfig create-attribute-mapping --map-name "Attr Map" \
  --mapping-name ubidEmailJSON \
  --type json

bin/dsconfig create-json-attribute-mapping-field --map-name "Attr Map" \
  --mapping-name ubidEmailJSON \
  --field-name "value" \
  --from-attribute mail

For more information about these configuration object types, refer to the configuration reference guide.

You can also use a constructed attribute mapping to construct a JSON attribute value as a raw string, as follows:

$ bin/dsconfig create-attribute-mapping \
  --map-name "Attr Map" \
  --mapping-name ubidEmailJSON \
  --type constructed \
  --set 'value-pattern:{{"value" : "{mail:jsonEscape}"}}'

When constructing a value, be aware of the following points:

  • Double curly brackets ( {{ }}) are necessary to represent a single curly bracket ( { }) in the output. These brackets are typically used to reference attribute values.
  • Use the :jsonEscape modifier to escape attribute values that appear within a JSON attribute. This step prevents values that include quotes like '"John Smith" <jsmith@example.com>' from producing invalid JSON.

In the following example, a JSON Attribute object must be created because the destination value is likely to be augmented with additional information:

$ bin/dsconfig create-json-attribute \
  --pipe-name "A to B" \
  --class-name Users \
  --attribute-name ubidEmailJSON \
  --set id-field:value \
  --set include-field:value