cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

Json values all with the same name, how to parse?

I have the following array in PowerFlow.

 

[
{
"name": "Account Manager",
"value": "Joe Svoboda"
},
{
"name": "AutoTask Workplace",
"value": null
},
{
"name": "Backup Solution",
"value": "Datto"
},
{
"name": "Billing POC",
"value": null
}
]

 
I'm guessing I want to strip out the "name" and "value" for each object leaving a useable array?
 
I've tried a replace, but that failed, I'm open to suggestions. 
 
Thanks in advance.
1 ACCEPTED SOLUTION

Accepted Solutions

Hey @JoeSvoboda 

 

Got it. Here you go:

Screenshot 2020-07-23 at 20.41.19.png

 

Explaining the steps:

1. Initialize a variable with your string to be able to parse it.

Screenshot 2020-07-23 at 20.44.46.png

2. Replace all null records by "". This is important because you'll want to create a JSON, and it will fail if there are null values. The formula is simple:

replace(variables('TEST'),'null','""')

Screenshot 2020-07-23 at 20.44.49.png

3. Get the JSON. Press "Generate from Sample" and paste your string to generate the structure. If it fails here's the correct one:

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "name": {
                "type": "string"
            },
            "value": {
                "type": "string"
            }
        },
        "required": [
            "name",
            "value"
        ]
    }
}

4. Create a variable to get your desired array

Screenshot 2020-07-23 at 20.44.55.png

5. Concatenate the values and add them to the array created before.

Screenshot 2020-07-23 at 20.44.58.png

In this step you can use also the "concat() function" to get exactly the combination of " and ":" that you want.

 

The result will be something like this:

[
  "Account Manager:Joe Svoboda",
  "AutoTask Workplace:",
  "Backup Solution:Datto",
  "Billing POC:"
]

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

View solution in original post

5 REPLIES 5
Super User II
Super User II

Hi @JoeSvoboda 

 

That's already a JSON array.

 

What do you want to get? Something like

["Account Manager":"Joe Svoboda",....]

 

or

 

["Account Manager","AutoTask Workplace"]

["Joe Svoboda",""]

 

Or something else?

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

Yes, I would like to strip out the "name" and "value" from each object.

 

["Account Manager":"Joe Svoboda",....]  would be the preferred outcome.

Hey @JoeSvoboda 

 

Got it. Here you go:

Screenshot 2020-07-23 at 20.41.19.png

 

Explaining the steps:

1. Initialize a variable with your string to be able to parse it.

Screenshot 2020-07-23 at 20.44.46.png

2. Replace all null records by "". This is important because you'll want to create a JSON, and it will fail if there are null values. The formula is simple:

replace(variables('TEST'),'null','""')

Screenshot 2020-07-23 at 20.44.49.png

3. Get the JSON. Press "Generate from Sample" and paste your string to generate the structure. If it fails here's the correct one:

{
    "type": "array",
    "items": {
        "type": "object",
        "properties": {
            "name": {
                "type": "string"
            },
            "value": {
                "type": "string"
            }
        },
        "required": [
            "name",
            "value"
        ]
    }
}

4. Create a variable to get your desired array

Screenshot 2020-07-23 at 20.44.55.png

5. Concatenate the values and add them to the array created before.

Screenshot 2020-07-23 at 20.44.58.png

In this step you can use also the "concat() function" to get exactly the combination of " and ":" that you want.

 

The result will be something like this:

[
  "Account Manager:Joe Svoboda",
  "AutoTask Workplace:",
  "Backup Solution:Datto",
  "Billing POC:"
]

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

View solution in original post

Manuel!

 

You the man!

 

That worked, I actually followed along with the logic and everything.  Now I just need to implement it in my current flow, but I feel pretty confident.

Thanks SO much for your assistance!

 

Joe

Hey @JoeSvoboda,

 

I'm glad I could help and even more that your issue is fixed.

 

Anything that you need to reach out and I'll be more than happy to help.

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

Helpful resources

Announcements
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (2,899)