How can I parse an array input?

Options
Hello!

Trying to parse webhooks from Sendgrid, but their API sends an array of objects, even if there’s just one (similar to below).

How can I use this data if the array doesn’t have any name? I’d need to know how many objects arrived, then loop each one. If I just have “example” as an input, then it won’t detect any data since it’s wrapped first inside the array that’s sent[Screen Shot 2022-08-16 at 3.26.32 PM.png]

Comments

  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    For Webhooks, I'd recommend using the Get All Input (Webhook) function under utilities. This will store the inputs in a variable so that you can use it as you would normally any variable in Xano
  •  This is the answer, thank you Michael! Gave it a test and it worked 🙂 The true Xano 🐐
  • Alimama
    Alimama Member
    Options
    This is essentially a list of objects, so create an endpoint as follow:
    1.  Create an input variable of type object list (send_grid_list)
    2.  Go to function stack - loop through  send_grid_list and get the data you need from each object in the loop e.g. send_grid_list.example and assign it to a variable var_1 (which is a list of integer). 
    3. Run and debug, it should give you a list of your examples values. In your case; [1,2].

    There are simpler ways, though.[711D89D1-FED7-4D51-BF7E-D7FDDF1D2A62.jpeg]