Forum Discussion

PaulPeterson1's avatar
PaulPeterson1
Qrew Assistant Captain
2 years ago

Looking for Jinja Sanity Check

I'm working with a pipeline that will retrieve a JSON object using a webhook.  I would prefer to do some logic in the pipeline rather than creating several new fields in the table.  In a few instances the JSON will have values in one of two related fields.  If they are able to scan a barcode there will be a value in the scan field, if not there will be a value in a related text field.

Here's the question, will the Jinja below yield the output discussed above:

{% if a.scan_value <> "" %}{{a.scan_value}}{% else%}{{a.text_value}}{% endif %}



------------------------------
Paul Peterson
------------------------------

2 Replies

  • DwightMunson1's avatar
    DwightMunson1
    Qrew Assistant Captain
    I would think it would be: 

    {% if a.scan_value != "" %}{{a.scan_value}}{% else%}{{a.text_value}}{% endif %}

    != is the comparison operator for inequality. 

    You could probably also do: 

    {% if a.scan_value is none %}{{a.text_value}}{% else%}{{a.scan_value}}{% endif %}

    ------------------------------
    Dwight Munson
    ------------------------------
    • PaulPeterson1's avatar
      PaulPeterson1
      Qrew Assistant Captain
      Thank you, I was close the first time.  I didn't use the same formatting when I tried it in the pipeline.  I had the {{}} around the scan value and the pipeline GUI gave me an error.  It went away when I removed the brackets.

      ------------------------------
      Paul Peterson
      ------------------------------