summaryrefslogtreecommitdiffstats
path: root/tests/syntax-tests/highlighted/JQ/sample.jq
blob: ba9c853f3613ea21bd6ed3c75569c44d1f43e665 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import "../imported-file" ;

# With Comments !
def weird($a; $b; $c):
	[ $a, $b, $c ] | transpose | reduce .[][] as $item (
		[];
		. + $item.property
	)
;

. | weird (.a; .b; .c) |

(

if (. | contains("never") ) then
	"Why yes"
else
	12.23
end

) as $never |

{
	hello,
	why: "because",
	hello: ( weird | ascii_upcase ),
	format_eg: ( . | @json "My json string \( . | this | part | just | white | ascii_upcase | transpose)" ),
	never: $never,
	"literal_key": literal_value,
	"this": 12.1e12,
	"part": "almost"
	"like": [
		12,
		2
		"json"
		{
			"quite": {
				similar: "but not quite"
			}
		}
	],
} | (
	
	# And with very basic brace matching
	
	# Invalid End
	]	
	
	# Other invalid ends
	( [ } ] )

	# A "valid" sequence
	( [  { key: () , other_key:( [ []  [[]] ]  ), gaga }  ] )

	# A "invalid" sequence
	( [  { key: () , other_key:( [ []  [[] ]  ), gaga }  ] )

	"A string\n whith escaped characters \" because we can"
)