Composing attributes with string interpolation

๐Ÿ“˜

About this guide

In this guide you will learn how to compose new attributes leveraging a combination of available attributes and constants with string interpolation.

JSON Syntax

Demyst allows the combining of results together into one attribute within refine (and within the input waterfalls section). Separators can be added right between the attributes. Below is an excerpt from a config, example values that these attributes would take, and the expected results.

{ 
  "refine": {  
    "complete_address": "${companies_house_company_profile.registered_office_address.address_line_1}, ${companies_house_company_profile.registered_office_address.address_line_2}"
  }  
}
{
	companies_house_company_profile.registered_office_address.address_line_1: "Cms Cameron Mckenna Llp Cannon Place",
	companies_house_company_profile.registered_office_address.address_line_2: "78 Cannon Street"
}
{  
  "refine": {  
    "complete_address": "Cms Cameron Mckenna Llp Cannon Place, 78 Cannon Street"
  }  
}

Should you be working within $extract or $dictionary, this functionality can take over the $at attribute path within select.

{  
  ...,  
  "refine": {  
    "my_schema": {  
      "$extract": {  
        "list_path": "companies_house_company_search.items",  
        "select": {  
          "full_address": "${address.address_line_1}, ${address.address_line_2}"  
        }  
      }  
    }  
  }  
}

You can also mix in any constant values you'd like outside of brackets. This may be used with or without separators.

{  
  ...,  
  "refine": {  
    "email_address": "${domain_from_email.user}@gmail.com"  
  }  
}

Example scenario

Seamless workflow experience: Perhaps your downstream systems require a person's name to be formatted as last_name followed by a , and then the first_name. Instead of adding code snippets for data transformation as an intermediate step between the Data API response and your downstream systems, simply use Demyst's string interpolation!

Flattened Array Transformation: You may want to pass search results to another provider. However, the response from your initial search provides a number of results in a hierarchical array. You can extract relevant attributes and transform them into a single string suitable for the format of the following provider.