Ask AI
Skip to main content

Map to attributes (jsonpath)

Function: Map to attributes (jsonpath)

This action helps you transform a list of complex data items into a new list where each item contains only specific pieces of information you choose. You define which parts of your original data you want to extract using "JSONPath" expressions, and you can even give these extracted pieces new, simpler names. This is useful for simplifying data or preparing it for display or further processing.

Input

  • Array:
    • Description: The original list of data items (objects) you want to process. Each item in this list should be a structured piece of information.
    • Type: List of items
    • Required: Yes
  • Jsonpaths:
    • Description: A list of instructions, where each instruction tells the system which specific piece of information to extract from each item in your original 'Array'.
    • Type: List of configurations
    • Each configuration in this list has two parts:
      • Jsonpath:
        • Description: A special text expression (like a map coordinate) that points directly to a single piece of data within each item. For example, $.customer.name would get the customer's name. You cannot use placeholders or templates here; it must be a direct path.
        • Type: Text
      • Field name:
        • Description: The new name you want to give to the extracted piece of data in your transformed list. If you leave this empty, the system will try to create a name based on your Jsonpath.
        • Type: Text
    • Required: Yes
  • Map to flat list:
    • Description: If you only specify one Jsonpath and set this to 'True', the final result will be a simple list of values (e.g., [value1, value2, value3]) instead of a list of objects (e.g., [\{key: value1\}, \{key: value2\}]). This is useful when you just need a single column of data.
    • Type: True/False value
    • Default Value: False
    • Required: Yes

Output

  • Result:
    • Description: The new list of transformed data items. Each item in this list will contain only the attributes you specified using your Jsonpaths.
    • Type: Stored value (List of items or a flat list of values)

Execution Flow

Real-Life Examples

Example 1: Extracting specific details from a list of orders

Imagine you have a list of customer orders, and you only want to see the order ID and the customer's email for each.

  • Inputs:
    • Array:
      [
      \{
      "orderId": "ORD-001",
      "customer": \{
      "name": "Alice Smith",
      "email": "[email protected]"
      \},
      "totalAmount": 120.50
      \},
      \{
      "orderId": "ORD-002",
      "customer": \{
      "name": "Bob Johnson",
      "email": "[email protected]"
      \},
      "totalAmount": 75.00
      \}
      ]
    • Jsonpaths:
      • Configuration 1:
        • Jsonpath: $.orderId
        • Field name: OrderID
      • Configuration 2:
        • Jsonpath: $.customer.email
        • Field name: CustomerEmail
    • Map to flat list: False
  • Result: The application will now have a new list stored in the Result variable, containing:
    [
    \{
    "OrderID": "ORD-001",
    "CustomerEmail": "[email protected]"
    \},
    \{
    "OrderID": "ORD-002",
    "CustomerEmail": "[email protected]"
    \}
    ]

Example 2: Getting a list of product names from an inventory

You have a list of products in your inventory, and you just need a simple list of all their names.

  • Inputs:
    • Array:
      [
      \{
      "productId": "P001",
      "name": "Laptop Pro",
      "price": 1200
      \},
      \{
      "productId": "P002",
      "name": "Wireless Mouse",
      "price": 25
      \},
      \{
      "productId": "P003",
      "name": "External Monitor",
      "price": 300
      \}
      ]
    • Jsonpaths:
      • Configuration 1:
        • Jsonpath: $.name
        • Field name: (empty)
    • Map to flat list: True
  • Result: The application will now have a new list stored in the Result variable, containing:
    [
    "Laptop Pro",
    "Wireless Mouse",
    "External Monitor"
    ]

Example 3: Creating a simplified user profile list

You have a list of user profiles with many details, but for a specific report, you only need their username and their last login date.

  • Inputs:
    • Array:
      [
      \{
      "id": "user123",
      "username": "john.doe",
      "email": "[email protected]",
      "lastLogin": "2023-10-26T10:00:00Z",
      "status": "active"
      \},
      \{
      "id": "user456",
      "username": "jane.smith",
      "email": "[email protected]",
      "lastLogin": "2023-10-25T14:30:00Z",
      "status": "inactive"
      \}
      ]
    • Jsonpaths:
      • Configuration 1:
        • Jsonpath: $.username
        • Field name: UserIdentifier
      • Configuration 2:
        • Jsonpath: $.lastLogin
        • Field name: LastActivity
    • Map to flat list: False
  • Result: The application will now have a new list stored in the Result variable, containing:
    [
    \{
    "UserIdentifier": "john.doe",
    "LastActivity": "2023-10-26T10:00:00Z"
    \},
    \{
    "UserIdentifier": "jane.smith",
    "LastActivity": "2023-10-25T14:30:00Z"
    \}
    ]