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

Community site session details

Session Id :
Power Automate
Unanswered

Escaping $ in JSON

(0) ShareShare
ReportReport
Posted on by 313

I want to end up with a JSON object that looks like this:

{"$content-type": "inputparameter1","$content": "inputparameter2"}

where the "inputparameter" strings are supplied via a PowerApps trigger (text and text_1). the JSON object is a parameter in a subsequent action.

I'm using a Compose action with this function:

json(concat('{','"$content-type":"',triggerBody()?['text'],'","$content":"',triggerBody()?['text_1'],'"}'))

but it fails. If I take the $ characters out, it succeeds.

I've tried '"\$content-type and '"%"$"%content-type but can't get it to work.

How can I escape a $ character when constructing a JSON object?

Categories:
I have the same question (0)
  • v-yueyun-msft Profile Picture
    on at
    Re: Escaping $ in JSON

    Hi , @JonathanGibbs 

    I test it in my side , it also give the internal error .

     For your need ,you can try to use the Select action to realize it .

    vyueyunmsft_0-1700788498845.png

    Then we can get the result as follows:

    vyueyunmsft_1-1700788521700.png

     

    Best Regards,

    Yueyun Zhang

     

     

  • Verified answer
    grantjenkins Profile Picture
    11,063 Moderator on at
    Re: Escaping $ in JSON

    I would use a variable of type Object instead of Compose which should work.

     

    grantjenkins_0-1700811625999.png

     

    json(concat('{', '"$content-type":"', triggerBody()['text'], '","$content":"', triggerBody()['text_1'], '"}'))

     

    grantjenkins_1-1700811663497.png

  • JonathanGibbs Profile Picture
    313 on at
    Re: Escaping $ in JSON

    @grantjenkins Thanks. Learned something new there about Compose vs Variable

    @v-yueyun-msft That's a neat solution YueYen - cleaner than the clunky text manipulation, perhaps. Need to isolate item [0] from the array of course

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
Tomac Profile Picture

Tomac 497 Moderator

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 477 Super User 2025 Season 2

#3
chiaraalina Profile Picture

chiaraalina 242

Last 30 days Overall leaderboard