Skip to main content
Question

Looking for Jinja Sanity Check

  • July 7, 2022
  • 0 replies
  • 43 views

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
------------------------------
This topic has been closed for replies.

DwightMunson1
Forum|alt.badge.img+8
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
------------------------------