For detailed guidance on expression please refer to this article: Conditional Expressions
The Encodian population engine provides additional features which allow the result of an expression to be formatted differently.
This article covers the following topics:
Expression Formatting Syntax
Expression formatting follows this simple convention:
<<[token]:"format">>
Consider this JSON document:
{
"companyName": "Encodian",
"formedOn": "17/06/2008"
}
Consider this standard expression format:
<<[formedOn]>>
Which generates the following output:
The expression result can be formatted by adding the format configuration, see below:
Formed: <<[formedOn]:"yyyy.MM.dd">>
Which generates the following output:
String Formats
The following string formats are supported by the population engine:
lower: Converts a string to lower case, for example: "this is a string"
Example JSON:
{
"product": "Encodian for Microsoft Power Automate"
}
Token Format Configuration
<<[product]:lower>>
Output:
upper: Converts a string to upper case, for example: "THIS IS A STRING"
Example JSON:
{
"product": "Encodian for Microsoft Power Automate"
}
Token Format Configuration
<<[product]:upper>>
Output:
caps: Capitalizes the first letter of every word in a string, for example: "This Is A String"
Example JSON:
{
"product": "encodian for microsoft power automate"
}
Token Format Configuration
<<[product]:caps>>
Output:
firstCap: Capitalizes the first letter of the first word in a string, for example: "This is a string"
Example JSON:
{
"product": "encodian for microsoft power automate"
}
Token Format Configuration
<<[product]:firstCap>>
Output:
Date Formats
By default, the population engine tries to detect and parse DateTime values automatically using the following formats listed in order:
- The ISO-8601 format (for values like “2015-03-02T13:56:04Z”)
- The Microsoft® JSON date-time format (for values like “/Date(1224043200000)/")
- All date-time formats supported for the current culture (Specific to processing region)
- All date-time formats supported for the English USA culture
- All date-time formats supported for the English New Zealand culture
The population engine supports the standard .NET date and time format strings. We've included a few examples below for reference:
Example #1
Example JSON:
{
"formedOn": "2008-08-10T13:49:51.141Z"
}
Token Format Configuration
<<[formedOn]:"dd MMM yy H:mm:ss">>
Output:
Example #2
Example JSON:
{
"formedOn": "2008-08-10T13:49:51.141Z"
}
Token Format Configuration
<<[formedOn]:"dd-MM-yyyy">>
Output:
Override Date Formatting
To override the default DateTime parsing configuration; please either set the 'Date Time Format' advanced property to:
- A specific format, for example: DD/MM/YYYY
- Specific formats using the '~' character, for example: MMMM dd, yyyy~DD/MM/YYYY
- The value 'disable' to prevent JSON values from being parsed as a DateTime
Number Formats
To ensure precision or to make longer numbers easier to read number formatting can be applied. A few common examples are shown below:
Example JSON:
{
"ThreeDP": 3.1415926,
"Millions": 2001032.91,
"MillionsWhole": 2001032.91
}
Example 1: Round to three decimal places
<<[ThreeDP]: "#,##0.#00">>
Output:
Example 2: Format a large number with commas
<<[Millions]: "#,##0.00">>
Output:
Example 3: Only show a whole number
<<[MillionsWhole]: "#,##0">>
Output:
Currency Formats
In a similar way to number formatting, currency formatting allows separators to be added to large numbers and decimal places to be limited. It also allows a currency symbol to be added. (this does not have to be the pound (£) symbol)
Example JSON:
{
"Money" : 10005.12345,
"NegativeMoney": -5.00,
}
Example 1: Rounded to 2DP with the currency symbol and commas added (this works for positive and negative numbers)
<<[Money]: "£#,##0.00">>
Output:
Example 2: Show the minus symbol after the currency symbol (this will cater for positive and negative numbers; only showing the negative symbol if appropriate)
<<[NegativeMoney]: "£#,##0.00;£-#,##0.00">>
Output:
All the above examples assume that the decimal separator is a period and the thousand separator is a comma. We are aware that for certain European countries this is not the case and so the following example caters for cases where comma is the decimal separator and period is the thousand separator.
Example JSON
{
"Money" : 10005.12
}
This example will use Germany so firstly make sure the Culture Name parameter is correct; a complete list can be found here
Example 3: Add the separators as shown below do not switch the comma and period. The Culture name parameter will change these to what they should be.
<<[Money]: "€#,##0.00">>
Output:
Note: Setting the correct Culture Name is important to prevent unexpected results. For example in Belgium, both French and English are used. Setting the culture as "fr-BE" would result in
€10 005,12
Whereas a culture of "en-BE" would result in
€10.005,12
Other Formats
The population engine also supports the following formats for numbers, the following examples all utilise this example JSON data:
{
"example": 1
}
alphabetic: Formats a number as an upper-case letter (A, B, C, …)
Token Format Configuration
<<[example]:alphabetic>>
Output:
roman: Formats a number as an upper-case Roman numeral (I, II, III, …)
Token Format Configuration
<<[example]:roman>>
Output:
ordinal: Appends an ordinal suffix to a number (1st, 2nd, 3rd, …)
Token Format Configuration
<<[example]:ordinal>>
Output:
ordinalText: Converts a number to its ordinal text representation (First, Second, Third, …)
Token Format Configuration
<<[example]:ordinalText>>
Output:
cardinal: Converts a number to its text representation (One, Two, Three, …)
Token Format Configuration
<<[example]:cardinal>>
Output:
hex: Formats a number as hexadecimal (8, 9, A, B, C, D, E, F, 10, 11, …)
Token Format Configuration
<<[example]:hex>>
Output:
arabicDash: Encloses a number with dashes (- 1 -, - 2 -, - 3 -, etc.)
Token Format Configuration
<<[example]:arabicDash>>
Output:
0 Comments