File tree 3 files changed +62
-0
lines changed
3 files changed +62
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,33 @@ Or use the `jsonpath.core <https://jsonpath.readthedocs.io/en/latest/api_core.ht
66
66
Contains(Self().Name("category"), Root().Name("targetCategory"))
67
67
).find(data) == [{"price": 100, "category": "Comic book"}]
68
68
69
+
70
+ Usage via CLI
71
+ ~~~~~~~~~~~~~
72
+
73
+ The faster way to extract by using CLI.
74
+
75
+ .. code-block :: shell
76
+
77
+ jp -f example.json " $.goods[contains(@.category, $.targetCategory)]"
78
+
79
+ Or pass content by pipeline.
80
+
81
+ .. code-block :: shell
82
+
83
+ cat example.json | jp " $.goods[contains(@.category, $.targetCategory)]"
84
+
85
+ The output of the above commands.
86
+
87
+ .. code-block :: json
88
+
89
+ [
90
+ {
91
+ "price" : 100 ,
92
+ "category" : " Comic book"
93
+ }
94
+ ]
95
+
69
96
Changelog
70
97
<<<<<<<<<
71
98
Original file line number Diff line number Diff line change @@ -49,3 +49,30 @@ Or use the :py:mod:`jsonpath.core` module to extract it.
49
49
assert Root().Name("goods").Predicate(
50
50
Contains(Self().Name("category"), Root().Name("targetCategory"))
51
51
).find(data) == [{"price": 100, "category": "Comic book"}]
52
+
53
+
54
+ Usage via CLI
55
+ ~~~~~~~~~~~~~
56
+
57
+ The faster way to extract by using CLI.
58
+
59
+ .. code-block :: shell
60
+
61
+ jp -f example.json " $.goods[contains(@.category, $.targetCategory)]"
62
+
63
+ Or pass content by pipeline.
64
+
65
+ .. code-block :: shell
66
+
67
+ cat example.json | jp " $.goods[contains(@.category, $.targetCategory)]"
68
+
69
+ The output of the above commands.
70
+
71
+ .. code-block :: json
72
+
73
+ [
74
+ {
75
+ "price" : 100 ,
76
+ "category" : " Comic book"
77
+ }
78
+ ]
Original file line number Diff line number Diff line change
1
+ {
2
+ "goods" : [
3
+ {"price" : 100 , "category" : " Comic book" },
4
+ {"price" : 200 , "category" : " magazine" },
5
+ {"price" : 200 , "no category" : " " }
6
+ ],
7
+ "targetCategory" : " book"
8
+ }
You can’t perform that action at this time.
0 commit comments