Examples: Functions for JSON-Type Projects


See working examples of functions for NLG Studio projects that use JSON data.

Enter your Studio email below to access this sample


Functions for JSON-Type Projects

This sample project demonstrates how to use the functions in JSON projects (Describe a JSON Object). Rather than showing a specific use case, this sample project simply helps you understand how to use the functions by providing working examples.

JSON projects generally use more complex data than is possible in a two-dimensional table. The JSON-specific functions here can handle complex JSON structures. For advanced users, the realise function provides access to lex rules.

Functions are demonstrated by showing the ATL required to call each function, both as readable text and as a working, executable example.

For more details on these functions, please consult the ATL Reference.

This sample project organizes functions into different categories. Each category is a separate script within the project as follows:

 

Data-access functions

  • asBoolean
  • asList
  • asNumber
  • asString
  • hasKey
  • keys
  • unique
  • value
  • values

Formatting functions

  • currency
  • formatNumber
  • now
  • today

Language functions

  • chooseAtRandom
  • countable
  • gender
  • inflectNoun
  • inflectVerb
  • list
  • numToWords
  • pronoun
  • realise

Math functions

  • abs
  • absDiff
  • diff
  • div
  • percentage
  • percentageChange
  • power
  • product
  • root
  • round
  • sign
  • sum

Text functions

  • charAt
  • contains
  • decodeHtml
  • encodeHtml
  • endsWith
  • indexOf
  • initCap
  • joinStrings
  • len
  • lower
  • split
  • startsWith
  • substitute
  • substring
  • titleCase
  • trim
  • upper

Advanced functions

  • filter
  • forAll
  • map
  • pairwiseMap
  • reduce