wildcard.json 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. [{
  2. "given": {
  3. "foo": {
  4. "bar": {
  5. "baz": "val"
  6. },
  7. "other": {
  8. "baz": "val"
  9. },
  10. "other2": {
  11. "baz": "val"
  12. },
  13. "other3": {
  14. "notbaz": ["a", "b", "c"]
  15. },
  16. "other4": {
  17. "notbaz": ["a", "b", "c"]
  18. },
  19. "other5": {
  20. "other": {
  21. "a": 1,
  22. "b": 1,
  23. "c": 1
  24. }
  25. }
  26. }
  27. },
  28. "cases": [
  29. {
  30. "expression": "foo.*.baz",
  31. "result": ["val", "val", "val"]
  32. },
  33. {
  34. "expression": "foo.bar.*",
  35. "result": ["val"]
  36. },
  37. {
  38. "expression": "foo.*.notbaz",
  39. "result": [["a", "b", "c"], ["a", "b", "c"]]
  40. },
  41. {
  42. "expression": "foo.*.notbaz[0]",
  43. "result": ["a", "a"]
  44. },
  45. {
  46. "expression": "foo.*.notbaz[-1]",
  47. "result": ["c", "c"]
  48. }
  49. ]
  50. }, {
  51. "given": {
  52. "foo": {
  53. "first-1": {
  54. "second-1": "val"
  55. },
  56. "first-2": {
  57. "second-1": "val"
  58. },
  59. "first-3": {
  60. "second-1": "val"
  61. }
  62. }
  63. },
  64. "cases": [
  65. {
  66. "expression": "foo.*",
  67. "result": [{"second-1": "val"}, {"second-1": "val"},
  68. {"second-1": "val"}]
  69. },
  70. {
  71. "expression": "foo.*.*",
  72. "result": [["val"], ["val"], ["val"]]
  73. },
  74. {
  75. "expression": "foo.*.*.*",
  76. "result": [[], [], []]
  77. },
  78. {
  79. "expression": "foo.*.*.*.*",
  80. "result": [[], [], []]
  81. }
  82. ]
  83. }, {
  84. "given": {
  85. "foo": {
  86. "bar": "one"
  87. },
  88. "other": {
  89. "bar": "one"
  90. },
  91. "nomatch": {
  92. "notbar": "three"
  93. }
  94. },
  95. "cases": [
  96. {
  97. "expression": "*.bar",
  98. "result": ["one", "one"]
  99. }
  100. ]
  101. }, {
  102. "given": {
  103. "top1": {
  104. "sub1": {"foo": "one"}
  105. },
  106. "top2": {
  107. "sub1": {"foo": "one"}
  108. }
  109. },
  110. "cases": [
  111. {
  112. "expression": "*",
  113. "result": [{"sub1": {"foo": "one"}},
  114. {"sub1": {"foo": "one"}}]
  115. },
  116. {
  117. "expression": "*.sub1",
  118. "result": [{"foo": "one"},
  119. {"foo": "one"}]
  120. },
  121. {
  122. "expression": "*.*",
  123. "result": [[{"foo": "one"}],
  124. [{"foo": "one"}]]
  125. },
  126. {
  127. "expression": "*.*.foo[]",
  128. "result": ["one", "one"]
  129. },
  130. {
  131. "expression": "*.sub1.foo",
  132. "result": ["one", "one"]
  133. }
  134. ]
  135. },
  136. {
  137. "given":
  138. {"foo": [{"bar": "one"}, {"bar": "two"}, {"bar": "three"}, {"notbar": "four"}]},
  139. "cases": [
  140. {
  141. "expression": "foo[*].bar",
  142. "result": ["one", "two", "three"]
  143. },
  144. {
  145. "expression": "foo[*].notbar",
  146. "result": ["four"]
  147. }
  148. ]
  149. },
  150. {
  151. "given":
  152. [{"bar": "one"}, {"bar": "two"}, {"bar": "three"}, {"notbar": "four"}],
  153. "cases": [
  154. {
  155. "expression": "[*]",
  156. "result": [{"bar": "one"}, {"bar": "two"}, {"bar": "three"}, {"notbar": "four"}]
  157. },
  158. {
  159. "expression": "[*].bar",
  160. "result": ["one", "two", "three"]
  161. },
  162. {
  163. "expression": "[*].notbar",
  164. "result": ["four"]
  165. }
  166. ]
  167. },
  168. {
  169. "given": {
  170. "foo": {
  171. "bar": [
  172. {"baz": ["one", "two", "three"]},
  173. {"baz": ["four", "five", "six"]},
  174. {"baz": ["seven", "eight", "nine"]}
  175. ]
  176. }
  177. },
  178. "cases": [
  179. {
  180. "expression": "foo.bar[*].baz",
  181. "result": [["one", "two", "three"], ["four", "five", "six"], ["seven", "eight", "nine"]]
  182. },
  183. {
  184. "expression": "foo.bar[*].baz[0]",
  185. "result": ["one", "four", "seven"]
  186. },
  187. {
  188. "expression": "foo.bar[*].baz[1]",
  189. "result": ["two", "five", "eight"]
  190. },
  191. {
  192. "expression": "foo.bar[*].baz[2]",
  193. "result": ["three", "six", "nine"]
  194. },
  195. {
  196. "expression": "foo.bar[*].baz[3]",
  197. "result": []
  198. }
  199. ]
  200. },
  201. {
  202. "given": {
  203. "foo": {
  204. "bar": [["one", "two"], ["three", "four"]]
  205. }
  206. },
  207. "cases": [
  208. {
  209. "expression": "foo.bar[*]",
  210. "result": [["one", "two"], ["three", "four"]]
  211. },
  212. {
  213. "expression": "foo.bar[0]",
  214. "result": ["one", "two"]
  215. },
  216. {
  217. "expression": "foo.bar[0][0]",
  218. "result": "one"
  219. },
  220. {
  221. "expression": "foo.bar[0][0][0]",
  222. "result": null
  223. },
  224. {
  225. "expression": "foo.bar[0][0][0][0]",
  226. "result": null
  227. },
  228. {
  229. "expression": "foo[0][0]",
  230. "result": null
  231. }
  232. ]
  233. },
  234. {
  235. "given": {
  236. "foo": [
  237. {"bar": [{"kind": "basic"}, {"kind": "intermediate"}]},
  238. {"bar": [{"kind": "advanced"}, {"kind": "expert"}]},
  239. {"bar": "string"}
  240. ]
  241. },
  242. "cases": [
  243. {
  244. "expression": "foo[*].bar[*].kind",
  245. "result": [["basic", "intermediate"], ["advanced", "expert"]]
  246. },
  247. {
  248. "expression": "foo[*].bar[0].kind",
  249. "result": ["basic", "advanced"]
  250. }
  251. ]
  252. },
  253. {
  254. "given": {
  255. "foo": [
  256. {"bar": {"kind": "basic"}},
  257. {"bar": {"kind": "intermediate"}},
  258. {"bar": {"kind": "advanced"}},
  259. {"bar": {"kind": "expert"}},
  260. {"bar": "string"}
  261. ]
  262. },
  263. "cases": [
  264. {
  265. "expression": "foo[*].bar.kind",
  266. "result": ["basic", "intermediate", "advanced", "expert"]
  267. }
  268. ]
  269. },
  270. {
  271. "given": {
  272. "foo": [{"bar": ["one", "two"]}, {"bar": ["three", "four"]}, {"bar": ["five"]}]
  273. },
  274. "cases": [
  275. {
  276. "expression": "foo[*].bar[0]",
  277. "result": ["one", "three", "five"]
  278. },
  279. {
  280. "expression": "foo[*].bar[1]",
  281. "result": ["two", "four"]
  282. },
  283. {
  284. "expression": "foo[*].bar[2]",
  285. "result": []
  286. }
  287. ]
  288. },
  289. {
  290. "given": {
  291. "foo": [{"bar": []}, {"bar": []}, {"bar": []}]
  292. },
  293. "cases": [
  294. {
  295. "expression": "foo[*].bar[0]",
  296. "result": []
  297. }
  298. ]
  299. },
  300. {
  301. "given": {
  302. "foo": [["one", "two"], ["three", "four"], ["five"]]
  303. },
  304. "cases": [
  305. {
  306. "expression": "foo[*][0]",
  307. "result": ["one", "three", "five"]
  308. },
  309. {
  310. "expression": "foo[*][1]",
  311. "result": ["two", "four"]
  312. }
  313. ]
  314. },
  315. {
  316. "given": {
  317. "foo": [
  318. [
  319. ["one", "two"], ["three", "four"]
  320. ], [
  321. ["five", "six"], ["seven", "eight"]
  322. ], [
  323. ["nine"], ["ten"]
  324. ]
  325. ]
  326. },
  327. "cases": [
  328. {
  329. "expression": "foo[*][0]",
  330. "result": [["one", "two"], ["five", "six"], ["nine"]]
  331. },
  332. {
  333. "expression": "foo[*][1]",
  334. "result": [["three", "four"], ["seven", "eight"], ["ten"]]
  335. },
  336. {
  337. "expression": "foo[*][0][0]",
  338. "result": ["one", "five", "nine"]
  339. },
  340. {
  341. "expression": "foo[*][1][0]",
  342. "result": ["three", "seven", "ten"]
  343. },
  344. {
  345. "expression": "foo[*][0][1]",
  346. "result": ["two", "six"]
  347. },
  348. {
  349. "expression": "foo[*][1][1]",
  350. "result": ["four", "eight"]
  351. },
  352. {
  353. "expression": "foo[*][2]",
  354. "result": []
  355. },
  356. {
  357. "expression": "foo[*][2][2]",
  358. "result": []
  359. },
  360. {
  361. "expression": "bar[*]",
  362. "result": null
  363. },
  364. {
  365. "expression": "bar[*].baz[*]",
  366. "result": null
  367. }
  368. ]
  369. },
  370. {
  371. "given": {
  372. "string": "string",
  373. "hash": {"foo": "bar", "bar": "baz"},
  374. "number": 23,
  375. "nullvalue": null
  376. },
  377. "cases": [
  378. {
  379. "expression": "string[*]",
  380. "result": null
  381. },
  382. {
  383. "expression": "hash[*]",
  384. "result": null
  385. },
  386. {
  387. "expression": "number[*]",
  388. "result": null
  389. },
  390. {
  391. "expression": "nullvalue[*]",
  392. "result": null
  393. },
  394. {
  395. "expression": "string[*].foo",
  396. "result": null
  397. },
  398. {
  399. "expression": "hash[*].foo",
  400. "result": null
  401. },
  402. {
  403. "expression": "number[*].foo",
  404. "result": null
  405. },
  406. {
  407. "expression": "nullvalue[*].foo",
  408. "result": null
  409. },
  410. {
  411. "expression": "nullvalue[*].foo[*].bar",
  412. "result": null
  413. }
  414. ]
  415. },
  416. {
  417. "given": {
  418. "string": "string",
  419. "hash": {"foo": "val", "bar": "val"},
  420. "number": 23,
  421. "array": [1, 2, 3],
  422. "nullvalue": null
  423. },
  424. "cases": [
  425. {
  426. "expression": "string.*",
  427. "result": null
  428. },
  429. {
  430. "expression": "hash.*",
  431. "result": ["val", "val"]
  432. },
  433. {
  434. "expression": "number.*",
  435. "result": null
  436. },
  437. {
  438. "expression": "array.*",
  439. "result": null
  440. },
  441. {
  442. "expression": "nullvalue.*",
  443. "result": null
  444. }
  445. ]
  446. },
  447. {
  448. "given": {
  449. "a": [0, 1, 2],
  450. "b": [0, 1, 2]
  451. },
  452. "cases": [
  453. {
  454. "expression": "*[0]",
  455. "result": [0, 0]
  456. }
  457. ]
  458. }
  459. ]