Undefined values: Difference between revisions

→‎{{header|jq}}: {}["key"] yields null
(jq)
(→‎{{header|jq}}: {}["key"] yields null)
Line 560:
 
=={{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 shjq>$ jq -n '1/0{}["key"] #==> null'</lang>
 
false</lang>
In jqan asimportant insense, JSONtherefore, null canin usuallyjq be used to representrepresents an undefined or unspecified 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,
2,484

edits