cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vnguyen1
Level: Powered On

how to combine all texts in json schema into one string using flow.

below is  my parsejason schema:

{
"type":"object",
"properties":{
"id":{"type":"string"},
"keywords":{"type":"array",
"items":{
"type":"object",
"properties":{
"keyword_id":{"type":"string"},
"text":{"type":"string"}
}
}
}
}
}
}

======================

output result:

{
"images": [
{
"id": "1135303410",
"keywords": [
{
"keyword_id": "60494",
"text": "Education",
"type": "Unknown",
"relevance": null
},
{
"keyword_id": "74709",
"text": "Pharmacy",
"type": "Unknown",
"relevance": null
},
{
"keyword_id": "60004",
"text": "People",
"type": "Unknown",
"relevance": null
}}

Goal : combine all the texts for each return keyword into a string as 

combinekeywords: 'Education,PharmacyPeople'. 

Anyone has any sugesstion or idea how to get this done ? Thanks in advance

2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Support Team
Community Support Team

Re: how to combine all texts in json schema into one string using flow.

Hi @vnguyen1,

 

Your output and JSON Schema have some parenthesis errors, you can use the data I corrected below to test:

Output:

{
  "images": [
    {
      "id": "1135303410",
      "keywords": [
        {
          "keyword_id": "60494",
          "text": "Education",
          "type": "Unknown",
          "relevance": null
        },
        {
          "keyword_id": "74709",
          "text": "Pharmacy",
          "type": "Unknown",
          "relevance": null
        },
        {
          "keyword_id": "60004",
          "text": "People",
          "type": "Unknown",
          "relevance": null
        }
      ]
    }
  ]
}

Schema:

{
"type": "object",
"properties": {
"images": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"keywords": {
"type": "array",
"items": {
"type": "object",
"properties": {
"keyword_id": {
"type": "string"
},
"text": {
"type": "string"
},
"type": {
"type": "string"
},
"relevance": {}
},
"required": [
"keyword_id",
"text",
"type",
"relevance"
]
}
}
},
"required": [
"id",
"keywords"
]
}
}
}
}

Step 1: Put the data into the compose, then use the Parse JSON action to get the output of JSON.

Step 2: Initialize a String variable named comebinekeywords.

Annotation 2019-09-05 105019.pngStep 3: Add Append to String variable action to put the "text" + "," into it.

Step 4: Process the last "," character use the expression:

substring(variables('combinekeywords'),0,sub(length(variables('combinekeywords')),1))
Annotation 2019-09-05 105037.png

Please have a try, I hope it can help you.

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

vnguyen1
Level: Powered On

Re: how to combine all texts in json schema into one string using flow.

@v-litu-msft 

i found a solution. just set variable to reset combinekeyword to NULL before the loop run. it fixed the issue

View solution in original post

7 REPLIES 7
Community Support Team
Community Support Team

Re: how to combine all texts in json schema into one string using flow.

Hi @vnguyen1,

 

Your output and JSON Schema have some parenthesis errors, you can use the data I corrected below to test:

Output:

{
  "images": [
    {
      "id": "1135303410",
      "keywords": [
        {
          "keyword_id": "60494",
          "text": "Education",
          "type": "Unknown",
          "relevance": null
        },
        {
          "keyword_id": "74709",
          "text": "Pharmacy",
          "type": "Unknown",
          "relevance": null
        },
        {
          "keyword_id": "60004",
          "text": "People",
          "type": "Unknown",
          "relevance": null
        }
      ]
    }
  ]
}

Schema:

{
"type": "object",
"properties": {
"images": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"keywords": {
"type": "array",
"items": {
"type": "object",
"properties": {
"keyword_id": {
"type": "string"
},
"text": {
"type": "string"
},
"type": {
"type": "string"
},
"relevance": {}
},
"required": [
"keyword_id",
"text",
"type",
"relevance"
]
}
}
},
"required": [
"id",
"keywords"
]
}
}
}
}

Step 1: Put the data into the compose, then use the Parse JSON action to get the output of JSON.

Step 2: Initialize a String variable named comebinekeywords.

Annotation 2019-09-05 105019.pngStep 3: Add Append to String variable action to put the "text" + "," into it.

Step 4: Process the last "," character use the expression:

substring(variables('combinekeywords'),0,sub(length(variables('combinekeywords')),1))
Annotation 2019-09-05 105037.png

Please have a try, I hope it can help you.

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

vnguyen1
Level: Powered On

Re: how to combine all texts in json schema into one string using flow.

Thanks @v-litu-msft  i could be able to get all the keywords and put them in a string 🙂 Thanks for your help

vnguyen1
Level: Powered On

Re: how to combine all texts in json schema into one string using flow.

@v-litu-msft i try to apply this to a loop , the 1st run , they pick up correct value in the combinekey, however, the next value : the combine key still keep the 1st value and did not update the new value. how to make this dynamically ? everytime to run the loop ?

Thanks in advance


@vnguyen1 wrote:

Thanks @v-litu-msft  i could be able to get all the keywords and put them in a string 🙂 Thanks for your help



 

Thanks2019-09-17_22-32-50.png

apply to a loop.PNG

vnguyen1
Level: Powered On

Re: how to combine all texts in json schema into one string using flow.

keyword combine set up.PNG

@v-litu-msft look like the initial value keywordcombine having an issue, it is not refresh to pick up the value everytime in the loop. it is stuck at the 1st value only. please advice

 

thanks

Community Support Team
Community Support Team

Re: how to combine all texts in json schema into one string using flow.

Hi @vnguyen1,

 

Could you please post an instance of the data of "downloads"?

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

vnguyen1
Level: Powered On

Re: how to combine all texts in json schema into one string using flow.

parse find image ID.PNG

below is the json that i tried to each ID..
example for this run; i have total 8 downloaded asset on that day. i send these ID to search for theri keywords.. after that combine them by your guildline sucessfully. 
However, when i tried to put these in the loop. the 1st asset get the correct combinekeyword. however, the 2nd asset .. the combine keyword are the same as 1st keyword, it did not update the value ... 
this is 1st asset : correct value :" Education,...."
1st asset.PNG
this is 2nd asset : the output keep the same as 1st asset ... "Education,.." . it should be "people,..."
2nd asset.PNG
{
"type": "object",
"properties": {
"result_count": {
"type": "integer"
},
"downloads": {
"type": "array",
"items": {
"type": "object",
"properties": {
"date_downloaded": {
"type": "string"
},
"id": {
"type": "string"
}
},
"required": [
"date_downloaded",
"id"
]
}
}
}
}
 
Please advice
 
thanks in advance
vnguyen1
Level: Powered On

Re: how to combine all texts in json schema into one string using flow.

@v-litu-msft 

i found a solution. just set variable to reset combinekeyword to NULL before the loop run. it fixed the issue

View solution in original post

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Coming Soon: T-shirt Design Contest

Keep your eyes open for our upcoming T-shirt design contest!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Users online (5,991)