Jump to content

Empty string: Difference between revisions

→‎{{header|jq}}: contrast JSON strings with jq interpolation directives
(→‎{{header|jq}}: contrast JSON strings with jq interpolation directives)
Line 1,645:
 
=={{header|jq}}==
jq programs can read JSON strings as data and may contain JSON strings. This entry is focused on such strings and excludes from consideration interpolation directives, which have the form of strings but are not themselves valid JSON strings.
jq strings are JSON strings. The empty string literal is simply <tt>""</tt>. It can be assigned to a variable as illustrated by this example:<syntaxhighlight lang="jq">"" as $x </syntaxhighlight>If s is a string or an array, then the additive "zero" for s can be created by writing s[0:0]. That is, if s is a string, then s[0:0] will yield the empty string. This is useful when writing polymorphic functions.
 
jq strings are JSON strings. The empty string literal is simply <tt>""</tt>. It can be assigned to a variable as illustrated by this example:<syntaxhighlight lang="jq">"" as $x </syntaxhighlight>If s is a string or an array, then the additive "zero" for s can be created by writing s[0:0]. That is, if s is a string, then s[0:0] will yield the empty string. This is useful when writing polymorphic functions.
 
To determine whether a string, s, is empty:<syntaxhighlight lang="jq">s == ""
2,469

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.