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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Convert Multiple Strin...
Power Automate
Unanswered

Convert Multiple String with different values to JSON

(0) ShareShare
ReportReport
Posted on by

Hi everyone,

 

Do you know how to convert a string like below

 

[

"Product: A",

"Quantity: 2",

"Order Start Date: 21/3/2023",

"Order Term (Month): 4",

"",

"Product: B",

"Quantity: 10",

"Order Start Date: 21/7/2023",

"Order Term (Month): 12"

]

 

to something like JSON like below,

 

[

{"Product": "A"},

{"Quantity": "2"},

{"Order Start Date": "21/3/2023"},

{"Order Term (Month)": "4"},

 

{"Product": "B"},

{"Quantity": "10"},

{"Order Start Date": "21/7/2023"},

{"Order Term (Month)": "12"}

]

 

I want this output to parse in JSON and store in sharepoint list.

Categories:
I have the same question (1)
  • grantjenkins Profile Picture
    11,063 Moderator on at

    Will there always be 4 properties for each item?

    • Product
    • Quantity
    • Order Start Date
    • Order Term (Month)

    Based on that assumption, this will hopefully get what you're looking for.

     

    See full flow below. I'll go into each of the actions.

    grantjenkins_0-1679488094027.png

     

    Compose contains your data.

    grantjenkins_1-1679488597172.png

     

    Filter array removes the empty items. It uses the following expression.

    trim(item())

    grantjenkins_2-1679488676158.png

     

    Select uses the following expressions to build up each of the objects.

    //From (will get 4 items from your array at a time)
    chunk(body('Filter_array'), 4)
    
    //Map - keys
    trim(first(split(item()[0], ':')))
    trim(first(split(item()[1], ':')))
    trim(first(split(item()[2], ':')))
    trim(first(split(item()[3], ':')))
    
    //Map - values
    trim(last(split(item()[0], ':')))
    trim(last(split(item()[1], ':')))
    trim(last(split(item()[2], ':')))
    trim(last(split(item()[3], ':')))

    grantjenkins_3-1679488796016.png

     

    After running the flow, we would get the following output.

    [
     {
     "Product": "A",
     "Quantity": "2",
     "Order Start Date": "21/3/2023",
     "Order Term (Month)": "4"
     },
     {
     "Product": "B",
     "Quantity": "10",
     "Order Start Date": "21/7/2023",
     "Order Term (Month)": "12"
     }
    ]

    grantjenkins_4-1679488852853.png

  • sarahairis Profile Picture
    on at

    Hi @grantjenkins ,

     

    I forgot to put "Order End Date", I tried to make modified Select

     

    //From (will get 4 items from your array at a time)
    chunk(body('Filter_array'), 5)
    
    //Map - keys
    trim(first(split(item()[0], ':')))
    trim(first(split(item()[1], ':')))
    trim(first(split(item()[2], ':')))
    trim(first(split(item()[3], ':')))
    trim(first(split(item()[4], ':')))
    
    //Map - values
    trim(last(split(item()[0], ':')))
    trim(last(split(item()[1], ':')))
    trim(last(split(item()[2], ':')))
    trim(last(split(item()[3], ':')))
    trim(last(split(item()[4], ':')))

     

    but I got an error below,

    sarahairis_0-1679501078701.png

     

  • grantjenkins Profile Picture
    11,063 Moderator on at

    Can you confirm that you used is not equal to in the Filter array? It looks like no data is coming through.

     

    grantjenkins_0-1679525612919.png

     

    If you do already have that filter as shown above - can you show the output you are getting from your Filter array when you run the flow.

  • sarahairis Profile Picture
    on at

    @grantjenkins ,

     

    Yes, I leave it blank,

    sarahairis_0-1679538076634.png

     

    this is the output,

     

    sarahairis_1-1679538229988.png

     

  • sarahairis Profile Picture
    on at

    Hi @grantjenkins ,

     

    When I use

    chunk(body('Filter_array'), 4)

    or

    chunk(body('Filter_array'), 6)

    there is no error but I will not get 5 properties in each item in order. That's strange, I don't know what's the root cause of it. 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 921

#2
Valantis Profile Picture

Valantis 801

#3
Haque Profile Picture

Haque 588

Last 30 days Overall leaderboard