bat/tests/syntax-tests/highlighted/JQ/sample.jq

61 lines
8.9 KiB
Text
Raw Normal View History

2022-02-12 19:18:21 +00:00
import "../imported-file" ;
# With Comments !
def weird($a; $b; $c):
 [ $a, $b, $c ] | transpose | reduce .[][] as $item (
 [];
 . + $item.property
 )
2022-02-12 19:18:21 +00:00
;
. | weird (.a; .b; .c) |
2022-02-12 19:18:21 +00:00
(
if (. | contains("never") ) then
2022-02-12 19:18:21 +00:00
 "Why yes"
else
 12.23
end
) as $never |
2022-02-12 19:18:21 +00:00
{
 hello,
 why: "because",
 hello: ( weird | ascii_upcase ),
 format_eg: ( . | @json "My json string \( . | this | part | just | white | ascii_upcase | transpose)" ),
 never: $never,
2022-02-12 19:18:21 +00:00
 "literal_key": literal_value,
 "this": 12.1e12,
 "part": "almost"
 "like": [
 12,
 2
 "json"
 {
 "quite": {
 similar: "but not quite"
 }
 }
 ],
} | (
2022-02-12 19:18:21 +00:00
 
 # And with very basic brace matching
 
 # Invalid End
 ] 
 
 # Other invalid ends
 ( [ } ] )
2022-02-12 19:18:21 +00:00
 # A "valid" sequence
 ( [ { key: () , other_key:( [ [] [[]] ] ), gaga } ] )
2022-02-12 19:18:21 +00:00
 # A "invalid" sequence
 ( [ { key: () , other_key:( [ [] [[] ] ), gaga } ] )
2022-02-12 19:18:21 +00:00
 "A string\n whith escaped characters \" because we can"
)