Parse JSON field value in Pipelines based on another field value from the object
Hi All,
I'm trying to parse a specific value from the JSON. I'm trying to get the value of the "display_value" where the object's GID is equal to "1205664665921946". I need to get it based on the GID field value because the order of the custom_field objects can change.
JSON sample (yellow number is what I need to parse)
Method 1: Filter query
I tried using filter queries in the Iterate over JSON records step, but I get "Found no JSON object items" in the activity log. See this screenshot for the filter.
I then use this formula in the Regex step to extract the number from the URL: {{c.data_0.custom_fields[0].display_value}}
Method 2: Jinja
I also tried using this Jinja, but I'm getting an error: "Validation error: {'text': 'required field'}"
{% set target_gid = "1205664665921946" %}
{% set url = "" %}
{% for custom_field in c.data_0.custom_fields %}
{% if custom_field.gid == target_gid %}
{% set url = custom_field.display_value|string %}
{% endif %}
{% endfor %}
{{ url }}
------------------------------
Frontman
------------------------------