cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
seadude
Memorable Member
Memorable Member

JSON object to array

Hello. 


I'm trying out Flow a little deeper and have lots of questions (fun!).

 

Simple project:

  1. Hit the Github emoji api
  2. Get all emojis
  3. Convert from JSON object to array(?)
  4. Send all emojis to a sharepoint list with two columns
    1. emoji_name
    2. url

So far:

  1. Created the Sharepoint list with 2 columns correctly named
  2. Created the HTTP GET request to https://api.github.com/emojis
  3. It returns a JSON object of all emojis
  4. I cant seem to find a way to convert this from JSON object to somthing Sharepoint will ingest. 

Any ideas? 

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
gamoraes
Memorable Member
Memorable Member

Hi @seadude

 

I create a flow to solve your problem.

 

Starting with your step 3,

 

 

Using a Compose action we can split each line using the ',', don't forget replace the '{' and '}'. The expression that you need is:

 

split(replace(replace(string(body('YOUR HTTP ACTION NAME')),'{',''),'}',''),',')

After i use a apply to each and inside split the 'key'(name of emoji) and 'value'(url of emoji)

To get it respectively use this expressions:

 

first(split(items('YOUR APPLY TO EACH NAME'),':'))
last(split(items('YOUR APPLY TO EACH NAME'),':'))

The result is this:Flow 1.png

 

 

 

After this is easy to insert in SP using the Create Item action

 

Look at my flow result:

Flow 2.png

 

 

 

Thanks for this post Smiley Wink

 

Best Regards,

 

Gustavo Moraes

 


Did I answer your question? Mark my post as a solution!

Gustavo Moraes, o astronauta brasileiro do Flow!


View solution in original post

12 REPLIES 12
gamoraes
Memorable Member
Memorable Member

Hi @seadude

 

I create a flow to solve your problem.

 

Starting with your step 3,

 

 

Using a Compose action we can split each line using the ',', don't forget replace the '{' and '}'. The expression that you need is:

 

split(replace(replace(string(body('YOUR HTTP ACTION NAME')),'{',''),'}',''),',')

After i use a apply to each and inside split the 'key'(name of emoji) and 'value'(url of emoji)

To get it respectively use this expressions:

 

first(split(items('YOUR APPLY TO EACH NAME'),':'))
last(split(items('YOUR APPLY TO EACH NAME'),':'))

The result is this:Flow 1.png

 

 

 

After this is easy to insert in SP using the Create Item action

 

Look at my flow result:

Flow 2.png

 

 

 

Thanks for this post Smiley Wink

 

Best Regards,

 

Gustavo Moraes

 


Did I answer your question? Mark my post as a solution!

Gustavo Moraes, o astronauta brasileiro do Flow!


Hello @gamoraes

 

I'm working my way through your answer. 

 

What do you mean by 'YOUR HTTP ACTION NAME' and 'YOUR APPLY TO EACH NAME'?

 

I feel like the name of my http action is 'HTTP', but that doesn't work in the expression. 

I feel like the name of my apply to each is the default "Apply to each", but that doesn't work in the expression. 

 

Screenshot from 2018-07-28 22-13-44.png


Can you give me some more details? 

 

Thank you very much!

Looks like I was missing the "_" between spaced words in the "Apply to each" title.

 

When I changed the First and Last formulas to contain 'Apply_to_each', the Flow was successful! I can click the right and left arrows to move through the results. 

 

Awesome help @gamoraes. You have skills!

 

Screenshot from 2018-07-28 23-23-07.png

seadude
Memorable Member
Memorable Member

Aha! Notice though that the `Last` expression is actually cutting the `https:` off of the URL becuase of the " : ". Tricky. Do you have ideas how I can: 

 

  • Keep the `https:` prefix for the URL
  • Remove all " " " (double quotes) from the Name and Url?


Thanks for your time!

Hi @gamoraes

 

I figured this out with a little help from another buddy. All good now!

 

Thanks!

Hi @seadude.

 

Cool that you have win! 🙂

 

Just for knowledge here is the solutions for you:

 

DONT FORGET TO CHANGE THE ACTIONS NAME, IN THIS CASE 'Aplicar_a_cada' to your apply to each action name and 'Http' to your http action name

 

  • Keep the `https:` prefix for the URL
    • Replace the last compose script to
    • substring(items('Aplicar_a_cada'),add(indexOf(items('Aplicar_a_cada'),':'),1),sub(length(items('Aplicar_a_cada')),add(indexOf(items('Aplicar_a_cada'),':'),1)))
    • In this new function i use substring,i get the index of first ':' more 1(to remove this) and the length minus the index
  • Remove all " " " (double quotes) from the Name and Url?
    • Replace the old split in first compose to this
    • split(replace(replace(replace(string(body('HTTP')),'{',''),'}',''),'"',''),',')

Did I answer your question? Mark my post as a solution!

Gustavo Moraes, o astronauta brasileiro do Flow!


My buddy and I hacked together this solution before your more elegant reply. It works too!

 

Screenshot from 2018-08-02 08-59-04.pngScreenshot from 2018-08-02 08-59-22.png

Shegs
Advocate II
Advocate II

I've got one that could use some help if you've got this figured out.

I'm getting these JSON objects from an API call that I'd like to convert into an array of objects (Users).

 

2018-09-27_11-28-12.jpg

I've tried replacing the "users" object brackets to square brackets but then it doesn't like the IDs and ":" before each array item. not sure how to replace those, as they can be any number and have any number of users returned.

 

I presume that after I get the string looking right, I can just pass that string into a parse JSON action and get an array I can loop through.

 

 

Good question. I haven't touched this one in a while and you know how that goes!

 

I think you're asking how to loop through the deeper levels of your JSON object and pull out the values, right?

 

I spent a few minutes looking through the Flow we came up with. Its different from yours, my objects are only one level deep.

 

Example:

{
  "100": "https://assets-cdn.github.com/images/icons/emoji/unicode/1f4af.png?v8",
  "1234": "https://assets-cdn.github.com/images/icons/emoji/unicode/1f522.png?v8",
  "+1": "https://assets-cdn.github.com/images/icons/emoji/unicode/1f44d.png?v8",
  "-1": "https://assets-cdn.github.com/images/icons/emoji/unicode/1f44e.png?v8",
  "1st_place_medal": "https://assets-cdn.github.com/images/icons/emoji/unicode

}

I'm just now sure! I exported my Flow and can email it to you if its of any use. Reaching out to @gamoraes here, he's solid in this area.

 

 

I can get it down to the displayed JSON  where each user object is under "users" but users isn't an array so each user is an object. with some simple regex-find/replace I am able to format the JSON in a way that it works, but I am unable to see a suitable way to handle that in the flow without buying another subscription to another service...

I'll do some more digging.

Thanks

Hi @Shegs. Just ran across a new @mr-dang video here. Check out the 14:00 mark. It appears he is using an Expression to dig a level deeper into the JSON.

 

Maybe it could help?

I actually found an amazing fix.

I was able to take the function on this page:

https://www.red-gate.com/simple-talk/sql/t-sql-programming/consuming-json-strings-in-sql-server/

 

and create a query that pivoted my JSON into rows that were then returned to flow as an array.

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,636)