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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Get json object that s...
Power Automate
Unanswered

Get json object that start with specific text

(0) ShareShare
ReportReport
Posted on by 31

Hi everybody, 

 

I've a json with a lot of objects inside an array. i've found a way to get a specific object via this function :

outputs('Prédire_à_l’aide_de_modèles_AI_Builder')?['body/responsev2/predictionOutput/results']?[0]?['lines']?[32]?['text']
 
This function permit to get the item n°32 but sometimes the item i need can be at position 30 or 34 ou 33 or other positions.
How can i get an json object where text startWith (CLASSE) ?
 
Many thanks. 
 
Regards
Categories:
I have the same question (0)
  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @jdos3502 

     

    Can you share some sample JSON?

     

    Thanks

     

    Damien

     

  • jdos3502 Profile Picture
    31 on at

    Hi @DamoBird365 

     

    i've finally found a way by using "Filter array" component. 

     

    But now i'm facing another problem. I'm using AI Builder to scan PDF file. Here's a sample of the scan output

     

    {
     "@odata.type": "#Microsoft.Dynamics.CRM.expando",
     "text": "Section cadastrale :",
     "boundingBox": {
     "@odata.type": "#Microsoft.Dynamics.CRM.expando",
     "left": 0.5460617868076816,
     "top": 0.29067758927349846,
     "width": 0.1341981388932587,
     "height": 0.0081577507182925,
     "polygon": {
     "@odata.type": "#Microsoft.Dynamics.CRM.expando",
     "coordinates@odata.type": "#Collection(Microsoft.Dynamics.CRM.crmbaseentity)",
     "coordinates": [
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.expando",
     "x": 0.5460617868076816,
     "y": 0.29067758927349846
     },
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.expando",
     "x": 0.6802599257009403,
     "y": 0.29067758927349846
     },
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.expando",
     "x": 0.6802599257009403,
     "y": 0.29883533999179096
     },
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.expando",
     "x": 0.5460617868076816,
     "y": 0.29883533999179096
     }
     ]
     }
     }
     },
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.expando",
     "text": "AB n°621",
     "boundingBox": {
     "@odata.type": "#Microsoft.Dynamics.CRM.expando",
     "left": 0.5457350645578964,
     "top": 0.30840402243809,
     "width": 0.06258546206996696,
     "height": 0.008106444110001387,
     "polygon": {
     "@odata.type": "#Microsoft.Dynamics.CRM.expando",
     "coordinates@odata.type": "#Collection(Microsoft.Dynamics.CRM.crmbaseentity)",
     "coordinates": [
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.expando",
     "x": 0.5457350645578964,
     "y": 0.30840402243809
     },
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.expando",
     "x": 0.6083205266278634,
     "y": 0.30840402243809
     },
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.expando",
     "x": 0.6083205266278634,
     "y": 0.3165104665480914
     },
     {
     "@odata.type": "#Microsoft.Dynamics.CRM.expando",
     "x": 0.5457350645578964,
     "y": 0.3165104665480914
     }
     ]
     }
     }
     }

     

     

    The first object begins every time with "Section cadastrale" but the second object contain an ID which is different on every PDF file.

     

    My question is. How can i do to get the next object to "Section cadastrale" ? 

     

    Thanks for help

     

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    You should be able to select the object by integer?  If there are two, integer position starts at 0, so this is no 1.

     

    Some like 

    variables('array')?[1]
     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

  • jdos3502 Profile Picture
    31 on at

    There around 40 items. 

    I've tried this : outputs('Prédire_à_l’aide_de_modèles_AI_Builder')?['body/responsev2/predictionOutput/results']?[0]?['lines']?[32]?['text']

    but it's not working because sometimes the item i need can be at position 33 or 31. 

    That's why my idea was to get the next item to item that contain (Section Cadastrale) because the item i need is just the next item to section cadastrale. 

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @jdos3502 

     

    I forgot about that requirement. Why don’t you repurpose the array? Create a select action with the from being a range(0,length(array))

     

    the key, values can be 

    item:string

    index:item() which is the range 0 to length

     

    Then you can filter the array for item equals

    Section cadastrale

    get the index from the result and then add 1 to get you the index for the object of the original array.

     

    Hope that makes sense, I’m on my phone 😉

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

  • jdos3502 Profile Picture
    31 on at

    That's a great idea but the initial JSON extracted from AI Builder contains 2600 rows 

     

    There's no index function by default ?

    I have 3000 pdf files to integrate and 2600 rows extracted by AI builder per file. 

     

    Many thanks. 

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @jdos3502 

     

    I will explain it with an example.  If I have understood correctly you are looking to select the object after the object with Item containing "Section cadastrale :"?  The existing array has no index.

     

    Here I have a sampe array with 100 objects.

     

    DamoBird365_0-1622007006562.png

     

    You can create a temporary array in a compose to create an index, perform a filter on the text key and then add 1 to the index of your found key to return the next object.

     

    DamoBird365_1-1622007133675.png

     

    The output is as follows:

    DamoBird365_2-1622007162566.png

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

     

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @jdos3502 

     

    Did that work for you?

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

  • jdos3502 Profile Picture
    31 on at

    Hi @DamoBird365 

     

    Thanks for your reply. 

    Do you have more details about how can i implement it with my need ? 

     

    I currently found a solution but too long for end users 

    Currently the user open a Power apps via a simple button in the CRM ribbon. 

    This power apps contain attachment control to attach PDF files.

     

    So the user attach the PDF files and click save.

     

    The Power automate is looping to all files to do a prediction with AI builder (scanning text) and it create a record in the CRM with text informations (Section cadastrale, address, ect...)

     

    Inside the attachments loop :

    1. i'm doing another loop to add index property on each items of the table (between 45 and 50 items).

    2. I'm incrementing the index number for each items.

    3. Outside the index loop, i'm doing a filter of my table to get the item where texte property equal "Section cadastrale"

    4. After that i'm using a compose to get the next index by incrementing +1 the section cadastrale index.  

     

    Here's a part of the Power automate steps i'm doing : 

     

    1. Loop on each attachment, Predict with AI Builder, Get only the concerned table of 45-50 objects in order to loop on each items to create an auto incremented index : 

     

    jdos3502_2-1622281310068.png

     

    2. Filter the created table of 45-50 objects with index to get the Section Cadastrale index. Search in the table of 45-50 objects the item that contain the section cadastrale index +1. 

    jdos3502_3-1622281546907.png

     

    This process is too long and the user must wait 40 secondes to finish the attachment process (And for only 1 attachment).

     

    Do you have another way to do this ? 20 sec per attachment can be a great deal. Or maybe by doing an asynchronous process ? 

     

    Many thanks again for your help. 

     

    Regards, 

     

  • DamoBird365 Profile Picture
    8,942 Microsoft Employee on at

    Hi @jdos3502 

     

    I'm afraid I don't understand what you are doing in the embedded apply to each actions.  Never an efficient way to do things but I am struggling to understand what you are doing.  You can turn on concurrency for both of those but if you can explain to me why, I might be able to suggest a better method.  If they are attaching 1 file, why do you have to run the AI on multiple files?

     

    You've also created variables, which are only ever needed if you are going to update them.  A compose is just as good for a temporary, one off, storage space.

     

    When you run the flow, what does the history look like?  Where is the most time consumed?  What action?

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
    Cheers,
    Damien


    P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard