JSON Parser not Working on filter in Array

I want the value from JSON Parser from payload where the value of approval_status.id is 0 which is Array of Object
Expected Output: Admin

{
  "approvals": [
    {
      "id": 27000976322,
      "created_at": "2023-06-08T05:31:08Z",
      "updated_at": "2023-06-08T05:31:08Z",
      "approver_id": 27004111681,
      "approver_name": "Admin",
      "approval_type": 2,
      "user_id": 27003994305,
      "level": 1,
      "user_name": "Ritesh Yadav",
      "approval_status": {
        "id": 0,
        "name": "requested"
      },
      "delegatee": null,
      "latest_remark": ""
    },
    {
      "id": 27000976325,
      "created_at": "2023-06-08T05:31:31Z",
      "updated_at": "2023-06-08T05:31:31Z",
      "approver_id": 27003994308,
      "approver_name": "Jack",
      "approval_type": 1,
      "user_id": 27003994305,
      "level": 1,
      "user_name": "Ritesh Yadav",
      "approval_status": {
        "id": 2,
        "name": "requted"
      },
      "delegatee": null,
      "latest_remark": ""
    }
  ]
}

Did you try the workflow as well?
I have seen that the preview been empty and it still worked.

Yes, I have tried. We are not getting value form Array of Object

I have one like this that I have been trying to resolve. I request warranty data from Dell, and it returns like this.

[
  {
    "id": 1192858130,
    "serviceTag": "ABC123",
    "invalid": false,
    "entitlements": [
      {
        "itemNumber": "997-8366",
        "startDate": "2021-02-20T06:00:00Z",
        "endDate": "2022-02-21T05:59:59.637Z",
        "entitlementType": "INITIAL",
clipped

If I want the parsed item itemNumber, it will return nothing. But I can request the serviceTag item. Assuming this is because it’s in an array same as yours.

@matthew.hall There isn’t a method in the WFA to enumerate (e.g. for loop) through all values in an array and the documentation doesn’t have an in depth overview of the functionality in the JSON Parser. In the Parser, there is a context menu that allows you to add variables so you can create variables for the itemNumber (e.g. itemNumber1, itemNumber2) based on the index. Note the cc emails, we created cc_email_1 as index 0 of the Array:

It looks like this was actually fixed recently, so now if I request an email I’ll receive something like here’s your data “2022-02-21t05:59:59.637Z”.

My problem now is that the quotes are normally removed automatically if it’s not in an array like this, but now aren’t. That makes it impossible to pass back to the freshservice API because the expression builder seems to hate quotes.

By the way, this is how I’ve had it set for 3 months in the parser, so unfortuntately Rob at the time I had already done that.

I’m going to try playing around with the type to see if that gets it to change how it handles things.

Hi @matthew.hall ,

Glad it’s working again. Maybe look at a liquid filter: replace – Liquid template language (shopify.github.io)

Trying to get it done in the freshservice automator. If that doesn’t work, I can definitely run it as a weekly task off of my machine in powershell.

And I wouldn’t say it’s working again. It didn’t work in the first place, and this does not fully resolve the original request of this topic, which would output Admin. Instead it would output [“Admin”] or in my case [“ISO-date”].

Liquid filters can be used in Workflow Automator (WFA) placeholders.

Powerful Placeholders with Liquid Filters : Freshservice

The square brackets indicate an array, so try updating the variables to the array index to see if it parses out to a string.

$[0].entitlements[1].enddate[0]

That does pass in my API request. You’re awesome. Glad to know that’s a supported feature.