How to edit a JSON object inside an Azure Logic App
Tags: azure, cloud, json, logicapps
Published: 2023-02-10 13:42:35

---
title: How to edit a JSON object inside an Azure Logic App
published: true
date: 2023-02-09 12:37:00 UTC
tags: azure,cloud,json,logicapps
canonical_url: https://www.frankysnotes.com/2023/02/how-to-edit-json-object-inside-azure.html
---

I use Azure Logic Apps in many of my solutions, I find them so conviennant to integrate different systemes. Recently one of them was failling and by lookink at the error message: _The property value exceeds the maximum allowed size_, I knew what was wrong. I was tying to save a JSON object into a Storage table but one property was too long. For this particular case I didn't need the value contain in the property so the plan was to delete it. At first, I thought it wasn't possible to edit a variable of type object in a Logic Apps, but it is!

In this post I will show how to use [Compose](https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-perform-data-operations#compose-action) action and [setProperty](https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#setProperty) to perform data operations in Azure Logic Apps.

## The Context

First think to know is that the _Compose action_ does not update the the current object but creates a new one. In this demo the JSON object use is quite short to simplyfy the demo.

```json
{	
"firstname":"Frank",	
"lastname":"Boucher",	
"alias":"fboucheros",	
"bio":"With many years of experience in the IT industry, François (Frank) Boucher is a trusted Microsoft Azure professional whose expertise and bilingual service are relied upon in large Canadian markets (Ottawa and Montreal) as well as internationally. Among his many accolades, Francois has been awarded four times Microsoft Azure MVP status, named a Microsoft Azure Advisor, and Microsoft Azure P-Seller. Frank created the “Cloud 5 minutes” show. Where every second week, a new episode that answers a different technical question, is published both in French and English (cloud5mins.com). "
}
```

## The Details

The Logic App recieve a JSON object from the request body. This is transfom as an Person object. To empty the `bio` property the action Compose will be used.

![Overview of the Compose action in the LogicApp](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tgb7j1f440718yipmxhj.png)

Inside the Compose action, use the context menu to find `setProperty` in the Expression section. The expression `setProperty` takes three parameters: the object, the property name, and the edited value. In this demo the goal was to empty the property therefore and empty string will be assign like this:

  `setProperty(variables('Person'),'bio','')`.

The edited object is accessible from the output of the Compose action and this what will be return in the Response action.

![Logic App closeup](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/13upd34gskbcfmochq6n.png)

## The Result

By adding a single action it's possible to edit JSON object in a Logic App without requiring to use inline code or external tools. A demo wouldn't be complite without a end-to-end run so here the result of a HTTP POST to the Logic App passing the Person JSON and the returned result.

![Result of HTTP call](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/htn4e008jj9vqivet3wp.png)

### Video version

If you prefer, I also have a video version of this post.

{% youtube https://www.youtube.com/watch?v=2W1xf0rCoMQ %}

### Useful links

- 🔗 Compose Action: [https://c5m.ca/Compose](https://c5m.ca/Compose)
- 🔗 SetProperty: [https://c5m.ca/setProperty](https://c5m.ca/setProperty)

  

~ Frank