← Back to Tutorials
Beginner⏱️ 20 min

Data Operations — Compose, Parse JSON, Filter Array

Data Operations — Compose, Parse JSON, Filter Array

Learn how to manipulate and transform data within your Logic Apps workflows using built-in data operation actions.

Prerequisites

  • An Azure account with an active subscription
  • Basic familiarity with Logic Apps (see previous tutorial)
  • A Logic App (Consumption or Standard) created in the Azure portal

Sample Data

We'll use this sample order array throughout the tutorial:

[
  { "id": 1, "product": "Laptop", "price": 1200, "category": "Electronics", "inStock": true },
  { "id": 2, "product": "Desk Chair", "price": 350, "category": "Furniture", "inStock": true },
  { "id": 3, "product": "Monitor", "price": 800, "category": "Electronics", "inStock": false },
  { "id": 4, "product": "Notebook", "price": 15, "category": "Stationery", "inStock": true },
  { "id": 5, "product": "Keyboard", "price": 150, "category": "Electronics", "inStock": true }
]

1. Compose Action

The Compose action lets you create JSON objects, merge data, or construct any output without needing an external service.

Use Cases

  • Build a JSON payload to pass to a later action
  • Merge values from multiple sources into a single object
  • Store intermediate calculations

Step-by-Step

  1. In your Logic App designer, click + New step.
  2. Search for Compose under Data Operations.
  3. In the Inputs field, enter your JSON object or expression.

Example — Create a JSON object:

{
  "orderSummary": {
    "totalItems": 5,
    "generatedAt": "@{utcNow()}",
    "source": "AzureIntegrationHub"
  }
}

Example — Merge dynamic content:

{
  "fullName": "@{triggerBody()?['firstName']} @{triggerBody()?['lastName']}",
  "email": "@{triggerBody()?['email']}"
}

Screenshot: Compose action configuration

Tip: Use the Compose action output in subsequent steps by referencing outputs('Compose').


2. Parse JSON Action

The Parse JSON action takes a JSON string or object and produces typed dynamic content you can use in later steps.

Step-by-Step

  1. Add a Parse JSON action (under Data Operations).
  2. In Content, select the output from a previous step (e.g., an HTTP response body).
  3. In Schema, provide the JSON schema.

Generating a JSON Schema from a Sample Payload

  1. Click Use sample payload to generate schema.
  2. Paste your sample JSON:
{
  "id": 1,
  "product": "Laptop",
  "price": 1200,
  "category": "Electronics",
  "inStock": true
}
  1. Click Done. The schema is auto-generated:
{
  "type": "object",
  "properties": {
    "id": { "type": "integer" },
    "product": { "type": "string" },
    "price": { "type": "integer" },
    "category": { "type": "string" },
    "inStock": { "type": "boolean" }
  }
}

Screenshot: Parse JSON schema generation

Using Dynamic Content After Parsing

Once parsed, each property (e.g., product, price) appears as selectable dynamic content in subsequent actions.

Screenshot: Dynamic content from Parse JSON

Tip: If your payload may have optional fields, set "required": [] in the schema or mark fields as nullable to avoid runtime failures.


3. Filter Array Action

The Filter Array action returns only the items from an array that match a specified condition.

Step-by-Step

  1. Add a Filter array action.
  2. In From, provide the source array (e.g., output of a Parse JSON or Compose action).
  3. Set the condition using the Advanced mode expression or the visual editor.

Example — Filter electronics that are in stock:

  • From: @body('Parse_JSON')
  • Condition: @item()?['category'] is equal to Electronics AND @item()?['inStock'] is equal to true

Result:

[
  { "id": 1, "product": "Laptop", "price": 1200, "category": "Electronics", "inStock": true },
  { "id": 5, "product": "Keyboard", "price": 150, "category": "Electronics", "inStock": true }
]

Screenshot: Filter Array condition setup


4. Select Action

The Select action transforms each item in an array into a new shape (like a map function).

Step-by-Step

  1. Add a Select action.
  2. In From, provide the source array.
  3. In Map, define the output object shape using key-value pairs.

Example — Extract product name and price only:

  • From: @body('Filter_array')
  • Map:
KeyValue
ProductName@item()?['product']
Price@item()?['price']

Result:

[
  { "ProductName": "Laptop", "Price": 1200 },
  { "ProductName": "Keyboard", "Price": 150 }
]

Screenshot: Select action mapping


5. Create CSV Table / Create HTML Table Actions

These actions convert an array of objects into a CSV string or an HTML table.

Create CSV Table

  1. Add a Create CSV table action.
  2. In From, provide the array (e.g., output of the Select action).
  3. Choose Automatic columns (uses all properties) or Custom to pick specific columns.

Output:

ProductName,Price
Laptop,1200
Keyboard,150

Create HTML Table

  1. Add a Create HTML table action.
  2. In From, provide the array.
  3. Choose column mode.

Output:

<table>
  <thead><tr><th>ProductName</th><th>Price</th></tr></thead>
  <tbody>
    <tr><td>Laptop</td><td>1200</td></tr>
    <tr><td>Keyboard</td><td>150</td></tr>
  </tbody>
</table>

Screenshot: Create CSV and HTML table actions

Tip: Combine the HTML table output with the Office 365 connector to send formatted email reports.


Complete Workflow Example

Here's the full flow combining all actions:

  1. Trigger — When an HTTP request is received (with the sample order array)
  2. Parse JSON — Parse the request body with the order schema
  3. Filter Array — Keep only Electronics items in stock
  4. Select — Map to ProductName and Price
  5. Create HTML Table — Generate a formatted table
  6. Send Email — Send the HTML table in an email body

Screenshot: Complete data operations workflow


Tips for JSON Schema Generation

  • Always use Use sample payload to generate schema rather than writing schemas manually.
  • Test with multiple sample payloads to ensure all possible fields are captured.
  • For arrays, provide at least one item that includes all fields.
  • Add "required": [] if fields may be missing at runtime.
  • Use "type": ["string", "null"] for nullable fields.

Common Issues

IssueCauseSolution
"Invalid type. Expected String but got Null"A field is null but schema expects a stringUpdate schema to allow null: "type": ["string", "null"]
Parse JSON fails with "Invalid JSON"Input is a string, not an objectUse json() expression to convert: json(triggerBody())
Filter Array returns emptyCondition values are case-sensitiveUse toLower() on both sides of the comparison
Select action output has null valuesSource property name has a typoVerify property names match the parsed schema exactly
CSV table has wrong columnsUsing Automatic mode with inconsistent objectsSwitch to Custom columns and define explicitly
"ActionFailed" on Parse JSONSchema mismatch with actual payloadRegenerate schema from a current sample payload

Next Steps