Getting Started
Basic Concepts
Tutorials
Advanced Concepts
How-to Guides
Building integration flows
Data transformation
Integration patterns
Developing Components
Tenant Management
Components
CRM Components
ERP Components
E-Commerce Components
Basic Components
Utility Components
References
Sailor
Component Descriptor
Covered in this article
Related articles
Contracts and Workspaces Understanding credentials Data Sample Overview Creating your first integration flow Getting Started What is an integration component? What is an integration flow? What is a tenant? Take a tour of the product Creating a webhook flow Building a component in Java Building a component in Node.js Content-Based Routing Deploying a component How-to Guides Managing flow history Managing OAuth Clients Managing user roles in a tenant Managing Workspaces Mapping data Building real-time flows Sending data to a list of recipients REST API component Managing your SSH keys Managing your Teams/Components Allmysms component Amazon MWS component AMQP component AppDirect Component AWS Lambda component AWS SNS component Bazaarvoice component ChannelAdvisor component Code component Configuration component CSV component Docusign component Dun-and-bradstreet component Ebay component Edifact-parser component Email component Exact Online component Filter component Google PubSub component Google-shopping component Google-translate component Goto-webinar component Google Spreadsheets component Components JDBC Component JDBC Component JDBC Component Key-value-component component Ldap component Lightspeed-ecom component Lightspeed-retail component Lionbridge-translation component Magento1 component Magento2 component Mailchimp component Mandrillapp component Mapper component Microsoft Dynamics CRM component MsSQL component NetSuite component ODATA component Outlook component Petstore-nodejs component Pipedrive component Postgresql component Quickbooks-component component Request-reply component Rest API component Router component Salesforce-cpq component Salesfoce Component Sdl-translate component Sftp component Shopify-admin component Shopware component Simple-trigger component Smarty-streets component Soap component Splitter component Stripe component Sugar-crm component Timer component Twitter component Webhook component Xml component Component Descriptor Structure References Sailor compatibility matrix View Classes

Jsonata component

Dedicated data transformation component for elastic.io platform based on JSONata

Authentication

This component requires no authentication.

How it works

This component takes the incoming message body and applies the configured JSONata transformation on it. It uses a fact that JSONata expression is a superset of JSON document so that by default any valid JSON document is a valid JSONata expression.

For example let’s take this sample incoming message body:

{
  "Account": {
    "Account Name": "Firefly",
    "Order": [
      {
        "OrderID": "order103",
        "Product": [
          {
            "Product Name": "Bowler Hat",
            "ProductID": 858383,
            "SKU": "0406654608",
            "Description": {
              "Colour": "Purple",
              "Width": 300,
              "Height": 200,
              "Depth": 210,
              "Weight": 0.75
            },
            "Price": 34.45,
            "Quantity": 2
          },
          {
            "Product Name": "Trilby hat",
            "ProductID": 858236,
            "SKU": "0406634348",
            "Description": {
              "Colour": "Orange",
              "Width": 300,
              "Height": 200,
              "Depth": 210,
              "Weight": 0.6
            },
            "Price": 21.67,
            "Quantity": 1
          }
        ]
      }
    ]
  }
}

You can use following JSONata expressions to transform it:

{
	"account": Account."Account Name",
	"orderCount" : $count(Account.Order)
}

result of that transofrmation will be the following JSON document (jsonata link):

{
  "account": "Firefly",
  "orderCount": 1
}

I hope you’ve got the idea. Now you can also do something more complicated, like this array-to-array transformation:

{
    "account": Account."Account Name",
    "products": Account.Order.Product.({
    	"name": $."Product Name",
        "revenue": (Price * Quantity)
    }),
    "orderIDs": Account.Order[].(OrderID)
}

resulting in (jsonata link):

{
  "account": "Firefly",
  "products": [
    {
      "name": "Bowler Hat",
      "revenue": 68.9
    },
    {
      "name": "Trilby hat",
      "revenue": 21.67
    }
  ],
  "orderIDs": [
    "order103"
  ]
}

License

Apache-2.0 © elastic.io GmbH