Undefined values: Difference between revisions

Content added Content deleted
(jq)
(→‎{{header|jq}}: {}["key"] yields null)
Line 560: Line 560:


=={{header|jq}}==
=={{header|jq}}==
Given a JSON object, o, and a key, k, that is not present in that object, then o[k] evaluates to null, e.g.
In jq as in JSON, null can usually be used to represent an undefined or unspecified value. However, in jq, 1/0 does not yield null:
<lang sh>$ jq -n '1/0 == null'
<lang jq>{}["key"] #=> null</lang>

false</lang>
In an important sense, therefore, null in jq represents an undefined value. However, it should be noted that in jq, 1/0 does not yield null:
<lang jq>1/0 == null #=>false</lang>


It should also be noted that in jq, null can combine with other values to form non-null values. Specifically, for any JSON entity, e,
It should also be noted that in jq, null can combine with other values to form non-null values. Specifically, for any JSON entity, e,