cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

Change propery in JSON with array inside

I have json with like this:

{
"actions": {
"Initialize_variable": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "Parameter1",
"type": "String",
"value": "Value1"
}
]
}
}
}
}

 

How can I change the value of "value" field? For example from "Value1" to "Value2", I can change another properties of JSON using setProperty(), but I can't use this for the property in array:(

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
New Member

Re: Change propery in JSON with array inside

Hi @v-litu-msft 

 

Thank you for answer!

Nice try:)

 

But this solution return json without array:(
JSON in Test variable :
{
"actions": {
"Initialize_variable": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "Parameter1",
"type": "String",
"value": "Value1"
}
]
}
}
}
}

JSON in Compose Output:
{
"actions": {
"Initialize_variable": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": {
"name": "Parameter1",
"type": "String",
"value": "Value2"
}
}
}
}
}

In my case JSON is a Flow Definition JSON, where "variables" should contain an array.

View solution in original post

3 REPLIES 3
Highlighted
Community Support
Community Support

Re: Change propery in JSON with array inside

Hi @ampetrushenko,

 

You can check the setProperty() function Example 2 to learn how to set child property for parent property in a JSON object, this is workaround how to set the value to Value2:

 

setProperty(variables('Test'),'actions',setProperty(variables('Test')['actions'],'Initialize_variable',setProperty(variables('Test')['actions']['Initialize_variable'],'inputs',setProperty(variables('Test')['actions']['Initialize_variable']['inputs'],'variables', setProperty(variables('Test')['actions']['Initialize_variable']['inputs']['variables'][0],'value','Value2')))))

 

Annotation 2019-11-28 133004.png

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Highlighted
New Member

Re: Change propery in JSON with array inside

Hi @v-litu-msft 

 

Thank you for answer!

Nice try:)

 

But this solution return json without array:(
JSON in Test variable :
{
"actions": {
"Initialize_variable": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": [
{
"name": "Parameter1",
"type": "String",
"value": "Value1"
}
]
}
}
}
}

JSON in Compose Output:
{
"actions": {
"Initialize_variable": {
"runAfter": {},
"type": "InitializeVariable",
"inputs": {
"variables": {
"name": "Parameter1",
"type": "String",
"value": "Value2"
}
}
}
}
}

In my case JSON is a Flow Definition JSON, where "variables" should contain an array.

View solution in original post

Highlighted
New Member

Re: Change propery in JSON with array inside

Any suggestions?:(

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (5,664)