Question

API array of 'text' to array in business process?

Dear Community,

 

I retrieve the following from an API:

 

                        "AdresseerbaarObjectGeometrie Punt Coordinates": [

                            "0,00",

                            "0,00",

                            "0,00"

                        ],

 

This is a fixed array of 3 objects with X, Y, Z coordinates. I wish to use this array in my business process and simply use formula to set a variable to

 

x = coordinates[0]

y = coordinates[1]

 

However I am unable to use this notation or any other, I do not want to create a sub process to loop through these 3 objects.

 

 

Can you help me?

 

Like 0

Like

4 comments
Best reply

Hi Pascal,

Here's how I would do it. First, assuming the JSON looks something like this: 

{
    "_embedded": 
    {
        "adressen": [
            {
                "adresseerbaarObjectGeometrie": {
                    "punt": {
                        "coordinates": [
                            "0.00",
                            "0.01",
                            "0.02"
                        ]
                    }
                }
            }
        ]
    }
}

Second, when added to the web service, I've added 3 different body parameters inside of adressen. Be sure to make sure that the "is array" is not checked so you're treating each of these as text: 

  • adresseerbaarObjectGeometrie.punt.coordinates[0]
  • adresseerbaarObjectGeometrie.punt.coordinates[1]
  • adresseerbaarObjectGeometrie.punt.coordinates[2]

So at this point, it's as if there are three separate properties, instead of it being an array. You can now map each of these values as separate properties to the subprocess. 

Ryan

Hello Pascal,

Yes, you should be able to use the index of the elements in the array to access each. If you provide the full JSON response here I could help you with the expressions. Also, a useful tool to test the path expressions is https://jsonpath.com - you can paste in the JSON response and test getting the values you're after. 

Ryan

 

This is the full json path to X: $._embedded.adressen[:].adresseerbaarObjectGeometrie.punt.coordinates[0]

 

In Creatio I already seperated the object into adressen, so that will have to be a 'for loop' with a subprocess. So the eventual path would be: adresseerbaarObjectGeometrie.punt.coordinates[0] I believe.

Hi Pascal,

Here's how I would do it. First, assuming the JSON looks something like this: 

{
    "_embedded": 
    {
        "adressen": [
            {
                "adresseerbaarObjectGeometrie": {
                    "punt": {
                        "coordinates": [
                            "0.00",
                            "0.01",
                            "0.02"
                        ]
                    }
                }
            }
        ]
    }
}

Second, when added to the web service, I've added 3 different body parameters inside of adressen. Be sure to make sure that the "is array" is not checked so you're treating each of these as text: 

  • adresseerbaarObjectGeometrie.punt.coordinates[0]
  • adresseerbaarObjectGeometrie.punt.coordinates[1]
  • adresseerbaarObjectGeometrie.punt.coordinates[2]

So at this point, it's as if there are three separate properties, instead of it being an array. You can now map each of these values as separate properties to the subprocess. 

Ryan

You are amazing! Thanks! I did not think of using the response parameters to fill it in.

Show all comments