pipe.json 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. [{
  2. "given": {
  3. "foo": {
  4. "bar": {
  5. "baz": "subkey"
  6. },
  7. "other": {
  8. "baz": "subkey"
  9. },
  10. "other2": {
  11. "baz": "subkey"
  12. },
  13. "other3": {
  14. "notbaz": ["a", "b", "c"]
  15. },
  16. "other4": {
  17. "notbaz": ["a", "b", "c"]
  18. }
  19. }
  20. },
  21. "cases": [
  22. {
  23. "expression": "foo.*.baz | [0]",
  24. "result": "subkey"
  25. },
  26. {
  27. "expression": "foo.*.baz | [1]",
  28. "result": "subkey"
  29. },
  30. {
  31. "expression": "foo.*.baz | [2]",
  32. "result": "subkey"
  33. },
  34. {
  35. "expression": "foo.bar.* | [0]",
  36. "result": "subkey"
  37. },
  38. {
  39. "expression": "foo.*.notbaz | [*]",
  40. "result": [["a", "b", "c"], ["a", "b", "c"]]
  41. },
  42. {
  43. "expression": "{\"a\": foo.bar, \"b\": foo.other} | *.baz",
  44. "result": ["subkey", "subkey"]
  45. }
  46. ]
  47. }, {
  48. "given": {
  49. "foo": {
  50. "bar": {
  51. "baz": "one"
  52. },
  53. "other": {
  54. "baz": "two"
  55. },
  56. "other2": {
  57. "baz": "three"
  58. },
  59. "other3": {
  60. "notbaz": ["a", "b", "c"]
  61. },
  62. "other4": {
  63. "notbaz": ["d", "e", "f"]
  64. }
  65. }
  66. },
  67. "cases": [
  68. {
  69. "expression": "foo | bar",
  70. "result": {"baz": "one"}
  71. },
  72. {
  73. "expression": "foo | bar | baz",
  74. "result": "one"
  75. },
  76. {
  77. "expression": "foo|bar| baz",
  78. "result": "one"
  79. },
  80. {
  81. "expression": "not_there | [0]",
  82. "result": null
  83. },
  84. {
  85. "expression": "not_there | [0]",
  86. "result": null
  87. },
  88. {
  89. "expression": "[foo.bar, foo.other] | [0]",
  90. "result": {"baz": "one"}
  91. },
  92. {
  93. "expression": "{\"a\": foo.bar, \"b\": foo.other} | a",
  94. "result": {"baz": "one"}
  95. },
  96. {
  97. "expression": "{\"a\": foo.bar, \"b\": foo.other} | b",
  98. "result": {"baz": "two"}
  99. },
  100. {
  101. "expression": "foo.bam || foo.bar | baz",
  102. "result": "one"
  103. },
  104. {
  105. "expression": "foo | not_there || bar",
  106. "result": {"baz": "one"}
  107. }
  108. ]
  109. }, {
  110. "given": {
  111. "foo": [{
  112. "bar": [{
  113. "baz": "one"
  114. }, {
  115. "baz": "two"
  116. }]
  117. }, {
  118. "bar": [{
  119. "baz": "three"
  120. }, {
  121. "baz": "four"
  122. }]
  123. }]
  124. },
  125. "cases": [
  126. {
  127. "expression": "foo[*].bar[*] | [0][0]",
  128. "result": {"baz": "one"}
  129. }
  130. ]
  131. }]