Skip to main content

Notifications

Community site session details

Community site session details

Session Id : ODk74oyNe8j7saNUeTMsev
Power Automate - General Discussion
Answered

JSON object to array

Like (2) ShareShare
ReportReport
Posted on 28 Jul 2018 08:23:04 by 1,855

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

Categories:
  • Shegs Profile Picture
    87 on 08 Oct 2018 at 14:32:46
    Re: JSON object to array

    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.

  • seadude Profile Picture
    1,855 on 07 Oct 2018 at 00:57:42
    Re: JSON object to array

    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?

  • Shegs Profile Picture
    87 on 01 Oct 2018 at 17:15:54
    Re: JSON object to array

    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

  • seadude Profile Picture
    1,855 on 30 Sep 2018 at 04:28:13
    Re: JSON object to array

    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.

     

     

  • Shegs Profile Picture
    87 on 27 Sep 2018 at 18:33:13
    Re: JSON object to array

    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.

     

     

  • seadude Profile Picture
    1,855 on 02 Aug 2018 at 16:00:45
    Re: JSON object to array

    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

  • gamoraes Profile Picture
    1,040 on 30 Jul 2018 at 05:42:03
    Re: JSON object to array

    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')),'{',''),'}',''),'"',''),',')
  • seadude Profile Picture
    1,855 on 30 Jul 2018 at 05:08:44
    Re: JSON object to array

    Hi @gamoraes

     

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

     

    Thanks!

  • seadude Profile Picture
    1,855 on 29 Jul 2018 at 07:18:13
    Re: JSON object to array

    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!

  • seadude Profile Picture
    1,855 on 29 Jul 2018 at 06:24:38
    Re: JSON object to array

    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

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,700 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard