Burgers & Bytes
August 23, 2025

Manipulate JSON objects or arrays: using setProperty/addProperty

Aug 23, 2025  •  3   • 540 
Table of contents

In Power Automate, working with JSON objects and arrays is essential for building advanced, scalable, and maintainable flows. JSON acts as the backbone of data exchange, allowing you to represent structured information flexibly.

Two powerful expressions—setProperty() and addProperty()—unlock the ability to dynamically update, expand, and manipulate JSON objects.

This article explores what these functions do, why they matter, and how you can apply them in real-world automation scenarios.

Why Manipulate JSON in Power Automate?

Before diving into the syntax, let’s answer the bigger question: why bother manipulating JSON at all?

💡 For example: if you start a flow with multiple input parameters and create a separate variable for each one, every initialization counts as an API call. Instead, you can group them all into a single object add a Parse JSON to define schema and manage them with setProperty() or addProperty().

Understanding setProperty() and addProperty()

1. setProperty()

The setProperty() expression updates an existing property.

Syntax: setProperty(<object>, <propertyName>, <value>)

When to use:

2. addProperty()

The addProperty() expression adds a new property to a JSON object without overwriting existing ones. If the property already exists, the function fails (unlike setProperty()).

Syntax: addProperty(<object>, <propertyName>, <value>)

When to use:

Example

Example of a JSON object.

JSON object

Example of a JSON object including data. JSON object including data

Consider the following customer interaction data:

// Sample customer interaction data
{
  "customerId": "12345",
  "name": "John Doe",
  "email": "john@example.com",
  "purchase": {
    "product": "Smartphone",
    "price": 799.99,
    "date": "2024-03-17"
  }
}

Updating a property with setProperty()

Scenario: The customer updates their email address. You can use the following expression in a Compose action: setProperty(variables('CustomerProfile'), 'email', variables('CustomerData')?['email']) JSON setProperty

Output displays the updated email value:

JSON updated property

Result: The email property is updated while everything else remains untouched.

Adding a nested element with addProperty()

Scenario: You want to add a product field under purchase. Which will make it easier for use to refer in later actions. addProperty(variables('CustomerProfile'),'purchase',variables('CustomerData')?['purchase']?['product'])

JSON add property

Output displays the product value: JSON add property

Working with Parse JSON Action

While manipulating JSON objects is powerful, you’ll often need to access properties individually in other steps. This is where Parse JSON comes in:

⚠️ Important: If you add or remove properties, you must update the schema in the Parse JSON action to prevent runtime errors.

Conclusion

By mastering setProperty() and addProperty(), you can build flows that are:

Instead of managing endless variables, think in JSON. With these two expressions, your flows become more robust, future-proof, and easier to maintain.

comments powered by Disqus
Empowering productivity - one blog at a time!