multiselect.json 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. [{
  2. "given": {
  3. "foo": {
  4. "bar": "bar",
  5. "baz": "baz",
  6. "qux": "qux",
  7. "nested": {
  8. "one": {
  9. "a": "first",
  10. "b": "second",
  11. "c": "third"
  12. },
  13. "two": {
  14. "a": "first",
  15. "b": "second",
  16. "c": "third"
  17. },
  18. "three": {
  19. "a": "first",
  20. "b": "second",
  21. "c": {"inner": "third"}
  22. }
  23. }
  24. },
  25. "bar": 1,
  26. "baz": 2,
  27. "qux\"": 3
  28. },
  29. "cases": [
  30. {
  31. "expression": "foo.{bar: bar}",
  32. "result": {"bar": "bar"}
  33. },
  34. {
  35. "expression": "foo.{\"bar\": bar}",
  36. "result": {"bar": "bar"}
  37. },
  38. {
  39. "expression": "foo.{\"foo.bar\": bar}",
  40. "result": {"foo.bar": "bar"}
  41. },
  42. {
  43. "expression": "foo.{bar: bar, baz: baz}",
  44. "result": {"bar": "bar", "baz": "baz"}
  45. },
  46. {
  47. "expression": "foo.{\"bar\": bar, \"baz\": baz}",
  48. "result": {"bar": "bar", "baz": "baz"}
  49. },
  50. {
  51. "expression": "{\"baz\": baz, \"qux\\\"\": \"qux\\\"\"}",
  52. "result": {"baz": 2, "qux\"": 3}
  53. },
  54. {
  55. "expression": "foo.{bar:bar,baz:baz}",
  56. "result": {"bar": "bar", "baz": "baz"}
  57. },
  58. {
  59. "expression": "foo.{bar: bar,qux: qux}",
  60. "result": {"bar": "bar", "qux": "qux"}
  61. },
  62. {
  63. "expression": "foo.{bar: bar, noexist: noexist}",
  64. "result": {"bar": "bar", "noexist": null}
  65. },
  66. {
  67. "expression": "foo.{noexist: noexist, alsonoexist: alsonoexist}",
  68. "result": {"noexist": null, "alsonoexist": null}
  69. },
  70. {
  71. "expression": "foo.badkey.{nokey: nokey, alsonokey: alsonokey}",
  72. "result": null
  73. },
  74. {
  75. "expression": "foo.nested.*.{a: a,b: b}",
  76. "result": [{"a": "first", "b": "second"},
  77. {"a": "first", "b": "second"},
  78. {"a": "first", "b": "second"}]
  79. },
  80. {
  81. "expression": "foo.nested.three.{a: a, cinner: c.inner}",
  82. "result": {"a": "first", "cinner": "third"}
  83. },
  84. {
  85. "expression": "foo.nested.three.{a: a, c: c.inner.bad.key}",
  86. "result": {"a": "first", "c": null}
  87. },
  88. {
  89. "expression": "foo.{a: nested.one.a, b: nested.two.b}",
  90. "result": {"a": "first", "b": "second"}
  91. },
  92. {
  93. "expression": "{bar: bar, baz: baz}",
  94. "result": {"bar": 1, "baz": 2}
  95. },
  96. {
  97. "expression": "{bar: bar}",
  98. "result": {"bar": 1}
  99. },
  100. {
  101. "expression": "{otherkey: bar}",
  102. "result": {"otherkey": 1}
  103. },
  104. {
  105. "expression": "{no: no, exist: exist}",
  106. "result": {"no": null, "exist": null}
  107. },
  108. {
  109. "expression": "foo.[bar]",
  110. "result": ["bar"]
  111. },
  112. {
  113. "expression": "foo.[bar,baz]",
  114. "result": ["bar", "baz"]
  115. },
  116. {
  117. "expression": "foo.[bar,qux]",
  118. "result": ["bar", "qux"]
  119. },
  120. {
  121. "expression": "foo.[bar,noexist]",
  122. "result": ["bar", null]
  123. },
  124. {
  125. "expression": "foo.[noexist,alsonoexist]",
  126. "result": [null, null]
  127. }
  128. ]
  129. }, {
  130. "given": {
  131. "foo": {"bar": 1, "baz": [2, 3, 4]}
  132. },
  133. "cases": [
  134. {
  135. "expression": "foo.{bar:bar,baz:baz}",
  136. "result": {"bar": 1, "baz": [2, 3, 4]}
  137. },
  138. {
  139. "expression": "foo.[bar,baz[0]]",
  140. "result": [1, 2]
  141. },
  142. {
  143. "expression": "foo.[bar,baz[1]]",
  144. "result": [1, 3]
  145. },
  146. {
  147. "expression": "foo.[bar,baz[2]]",
  148. "result": [1, 4]
  149. },
  150. {
  151. "expression": "foo.[bar,baz[3]]",
  152. "result": [1, null]
  153. },
  154. {
  155. "expression": "foo.[bar[0],baz[3]]",
  156. "result": [null, null]
  157. }
  158. ]
  159. }, {
  160. "given": {
  161. "foo": {"bar": 1, "baz": 2}
  162. },
  163. "cases": [
  164. {
  165. "expression": "foo.{bar: bar, baz: baz}",
  166. "result": {"bar": 1, "baz": 2}
  167. },
  168. {
  169. "expression": "foo.[bar,baz]",
  170. "result": [1, 2]
  171. }
  172. ]
  173. }, {
  174. "given": {
  175. "foo": {
  176. "bar": {"baz": [{"common": "first", "one": 1},
  177. {"common": "second", "two": 2}]},
  178. "ignoreme": 1,
  179. "includeme": true
  180. }
  181. },
  182. "cases": [
  183. {
  184. "expression": "foo.{bar: bar.baz[1],includeme: includeme}",
  185. "result": {"bar": {"common": "second", "two": 2}, "includeme": true}
  186. },
  187. {
  188. "expression": "foo.{\"bar.baz.two\": bar.baz[1].two, includeme: includeme}",
  189. "result": {"bar.baz.two": 2, "includeme": true}
  190. },
  191. {
  192. "expression": "foo.[includeme, bar.baz[*].common]",
  193. "result": [true, ["first", "second"]]
  194. },
  195. {
  196. "expression": "foo.[includeme, bar.baz[*].none]",
  197. "result": [true, []]
  198. },
  199. {
  200. "expression": "foo.[includeme, bar.baz[].common]",
  201. "result": [true, ["first", "second"]]
  202. }
  203. ]
  204. }, {
  205. "given": {
  206. "reservations": [{
  207. "instances": [
  208. {"id": "id1",
  209. "name": "first"},
  210. {"id": "id2",
  211. "name": "second"}
  212. ]}, {
  213. "instances": [
  214. {"id": "id3",
  215. "name": "third"},
  216. {"id": "id4",
  217. "name": "fourth"}
  218. ]}
  219. ]},
  220. "cases": [
  221. {
  222. "expression": "reservations[*].instances[*].{id: id, name: name}",
  223. "result": [[{"id": "id1", "name": "first"}, {"id": "id2", "name": "second"}],
  224. [{"id": "id3", "name": "third"}, {"id": "id4", "name": "fourth"}]]
  225. },
  226. {
  227. "expression": "reservations[].instances[].{id: id, name: name}",
  228. "result": [{"id": "id1", "name": "first"},
  229. {"id": "id2", "name": "second"},
  230. {"id": "id3", "name": "third"},
  231. {"id": "id4", "name": "fourth"}]
  232. },
  233. {
  234. "expression": "reservations[].instances[].[id, name]",
  235. "result": [["id1", "first"],
  236. ["id2", "second"],
  237. ["id3", "third"],
  238. ["id4", "fourth"]]
  239. }
  240. ]
  241. },
  242. {
  243. "given": {
  244. "foo": [{
  245. "bar": [
  246. {
  247. "qux": 2,
  248. "baz": 1
  249. },
  250. {
  251. "qux": 4,
  252. "baz": 3
  253. }
  254. ]
  255. },
  256. {
  257. "bar": [
  258. {
  259. "qux": 6,
  260. "baz": 5
  261. },
  262. {
  263. "qux": 8,
  264. "baz": 7
  265. }
  266. ]
  267. }
  268. ]
  269. },
  270. "cases": [
  271. {
  272. "expression": "foo",
  273. "result": [{"bar": [{"qux": 2, "baz": 1}, {"qux": 4, "baz": 3}]},
  274. {"bar": [{"qux": 6, "baz": 5}, {"qux": 8, "baz": 7}]}]
  275. },
  276. {
  277. "expression": "foo[]",
  278. "result": [{"bar": [{"qux": 2, "baz": 1}, {"qux": 4, "baz": 3}]},
  279. {"bar": [{"qux": 6, "baz": 5}, {"qux": 8, "baz": 7}]}]
  280. },
  281. {
  282. "expression": "foo[].bar",
  283. "result": [[{"qux": 2, "baz": 1}, {"qux": 4, "baz": 3}],
  284. [{"qux": 6, "baz": 5}, {"qux": 8, "baz": 7}]]
  285. },
  286. {
  287. "expression": "foo[].bar[]",
  288. "result": [{"qux": 2, "baz": 1}, {"qux": 4, "baz": 3},
  289. {"qux": 6, "baz": 5}, {"qux": 8, "baz": 7}]
  290. },
  291. {
  292. "expression": "foo[].bar[].[baz, qux]",
  293. "result": [[1, 2], [3, 4], [5, 6], [7, 8]]
  294. },
  295. {
  296. "expression": "foo[].bar[].[baz]",
  297. "result": [[1], [3], [5], [7]]
  298. },
  299. {
  300. "expression": "foo[].bar[].[baz, qux][]",
  301. "result": [1, 2, 3, 4, 5, 6, 7, 8]
  302. }
  303. ]
  304. },
  305. {
  306. "given": {
  307. "foo": {
  308. "baz": [
  309. {
  310. "bar": "abc"
  311. }, {
  312. "bar": "def"
  313. }
  314. ],
  315. "qux": ["zero"]
  316. }
  317. },
  318. "cases": [
  319. {
  320. "expression": "foo.[baz[*].bar, qux[0]]",
  321. "result": [["abc", "def"], "zero"]
  322. }
  323. ]
  324. },
  325. {
  326. "given": {
  327. "foo": {
  328. "baz": [
  329. {
  330. "bar": "a",
  331. "bam": "b",
  332. "boo": "c"
  333. }, {
  334. "bar": "d",
  335. "bam": "e",
  336. "boo": "f"
  337. }
  338. ],
  339. "qux": ["zero"]
  340. }
  341. },
  342. "cases": [
  343. {
  344. "expression": "foo.[baz[*].[bar, boo], qux[0]]",
  345. "result": [[["a", "c" ], ["d", "f" ]], "zero"]
  346. }
  347. ]
  348. },
  349. {
  350. "given": {
  351. "foo": {
  352. "baz": [
  353. {
  354. "bar": "a",
  355. "bam": "b",
  356. "boo": "c"
  357. }, {
  358. "bar": "d",
  359. "bam": "e",
  360. "boo": "f"
  361. }
  362. ],
  363. "qux": ["zero"]
  364. }
  365. },
  366. "cases": [
  367. {
  368. "expression": "foo.[baz[*].not_there || baz[*].bar, qux[0]]",
  369. "result": [["a", "d"], "zero"]
  370. }
  371. ]
  372. },
  373. {
  374. "given": {"type": "object"},
  375. "cases": [
  376. {
  377. "comment": "Nested multiselect",
  378. "expression": "[[*],*]",
  379. "result": [null, ["object"]]
  380. }
  381. ]
  382. },
  383. {
  384. "given": [],
  385. "cases": [
  386. {
  387. "comment": "Nested multiselect",
  388. "expression": "[[*]]",
  389. "result": [[]]
  390. }
  391. ]
  392. }
  393. ]