web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Flumoxed by addPropert...
Power Automate
Unanswered

Flumoxed by addProperty to JSON Object!

(0) ShareShare
ReportReport
Posted on by 11

Hi all - would really appreciate some help here. The end game is to dynamically add properties and values to a simple JSON object. But I'm falling at even the proof of concept stage witht he below really simple flow.. in the below addProperty doesn't seem to be updating the object, or in not the way I assumed it would.

Flow-1.png

 

the addProperty expression in AddFirstProperty :

addProperty(variables('ObjJSON'), 'PropertyName', 'PropertyValue')
(AddSecondProperty is the same except different PropertyName & PropertyValue)
 
So I would be expect something like the below in the output from the final step that I could then parse but it just shows as empty inside the curly brackets
{

"PropertyName" : "PropertyValue",

"PropertyName-2" : "PropertyValue-2"

}

Help much appreciated,

thanks

Categories:
I have the same question (0)
  • Verified answer
    cchannon Profile Picture
    4,702 Moderator on at

    You can't add a property to a json string, you can only add it to a deserialized json object. use the ParseJSON operation first, then addProperty to that (and make sure you only feed addProperty objects so it can properly infer type - if you just try to addProperty(myobj, "test", "test") it will fail).

    cchannon_0-1699456061091.png

     

    addProperty(body('Parse_JSON'), variables('test2'), variables('test2'))

     

  • DaveF1 Profile Picture
    11 on at

    thanhs cchannon (especially as I posted this in the wrong place).

    So you can't:

    1) Initialize an object {}

    2) add properties to that object inside a loop

    3) de-serialize the object later to access what you've added.

     

    Instead you addProperties to the deserialized object - then Set variable to overwrite the original empty object with added properties

  • cchannon Profile Picture
    4,702 Moderator on at

    Yeah, pretty much. All of the operations in Power Automate yield output values, but aren't inherrently variable modifiers; There isn't really a native "just do this operation on that value" kind of syntax. Instead, everything is about an output and then you assign that output to a thing (or in this case, back to the original obj)

  • DaveF1 Profile Picture
    11 on at

    Thanks cchannon - that's a relaly helpful explanantion - wish I'd asked a couple of days ago rather than consult chatgpt!! Cheers mate

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 523 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 406 Moderator

#3
abm abm Profile Picture

abm abm 245 Most Valuable Professional

Last 30 days Overall leaderboard