22
22
< section >
23
23
< h1 > USAGE</ h1 >
24
24
25
- < h2 > jsonjoin [OPTIONS] JSON_FILE_1 JSON_FILE_2</ h2 >
25
+ < h2 > jsonjoin [OPTIONS] JSON_FILE_1 [ JSON_FILE_2 …] </ h2 >
26
26
27
27
< h2 > SYSNOPSIS</ h2 >
28
28
29
- < p > jsonjoin is a command line tool that takes two (or more) JSON object
30
- documents and combines into a new JSON object document based on
31
- the options chosen.</ p >
29
+ < p > jsonjoin is a command line tool that takes one (or more) JSON objects files
30
+ and joins them to a root JSON object read from standard input (or
31
+ file identified by -input option). By default the resulting
32
+ joined JSON object is written to standard out.</ p >
33
+
34
+ < p > The default behavior for jsonjoin is to create key/value pairs
35
+ based on the joined JSON document names and their contents.
36
+ This can be thought of as a branching behavior. Each additional
37
+ file becomes a branch and its key/value pairs become leafs.
38
+ The root JSON object is assumed to come from standard input
39
+ but can be designated by the -input option or created by the
40
+ -create option. Each additional file specified as a command line
41
+ argument is then treated as a new branch.</ p >
42
+
43
+ < p > In addition to the branching behavior you can join JSON objects in a
44
+ flat manner. The flat joining process can be ether non-distructive
45
+ adding new key/value pairs (-update option) or distructive
46
+ overwriting key/value pairs (-overwrite option).</ p >
47
+
48
+ < p > Note: jsonjoin doesn’t support a JSON array as the root JSON object.</ p >
32
49
33
50
< h2 > OPTIONS</ h2 >
34
51
35
- < pre > < code > -h display help
52
+ < pre > < code > -create create an empty root object, {}
53
+ -h display help
36
54
-help display help
55
+ -i input filename (for root object)
56
+ -input input filename (for root object)
37
57
-l display license
38
58
-license display license
39
59
-o output filename
40
60
-output output filename
41
- -overwrite copy all key/values from second object into the first
42
- -update copy unique key/values from second object into the first
61
+ -overwrite copy all key/values into root object
62
+ -update copy new key/values pairs into root object
43
63
-v display version
44
64
-version display version
45
65
</ code > </ pre >
46
66
47
67
< h2 > EXAMPLES</ h2 >
48
68
49
- < h3 > Joining two JSON objects (maps)</ h3 >
69
+ < p > Consider two JSON objects one in person.json and another
70
+ in profile.json.</ p >
50
71
51
72
< p > person.json containes</ p >
52
73
@@ -59,22 +80,44 @@ <h3>Joining two JSON objects (maps)</h3>
59
80
"email": "
[email protected] " }
60
81
</ code > </ pre >
61
82
62
- < p > A simple join of person.json with profile.json</ p >
83
+ < p > A simple join of person.json with profile.json (note the
84
+ -create option)</ p >
85
+
86
+ < pre > < code class ="language-shell "> jsonjoin -create person.json profile.json
87
+ </ code > </ pre >
88
+
89
+ < p > would yeild and object like</ p >
90
+
91
+ < pre > < code class ="language-json "> {
92
+ "person": { "name": "Doe, Jane", "email":"
[email protected] ",
93
+ "age": 42},
94
+ "profile": { "name": "Doe, Jane", "bio": "World renowned geophysist.",
95
+ "email": "
[email protected] " }
96
+ }
97
+ </ code > </ pre >
98
+
99
+ < p > Likewise if you want to treat person.json as the root object and add
100
+ profile.json as a branch try</ p >
101
+
102
+ < pre > < code class ="language-shell "> cat person.json | jsonjoin profile.json
103
+ </ code > </ pre >
104
+
105
+ < p > or</ p >
63
106
64
- < pre > < code class ="language-shell "> jsonjoin person.json profile.json
107
+ < pre > < code class ="language-shell "> jsonjoin -i person.json profile.json
65
108
</ code > </ pre >
66
109
67
- < p > would yeild </ p >
110
+ < p > this yields an object like </ p >
68
111
69
112
< pre > < code class ="language-json "> {
70
- "
person": { " name": "Doe, Jane", "email":"
[email protected] ", "age": 42
} ,
113
+ "name": "Doe, Jane", "email":"
[email protected] ", "age": 42,
71
114
"profile": { "name": "Doe, Jane", "bio": "World renowned geophysist.",
72
115
"email": "
[email protected] " }
73
116
}
74
117
</ code > </ pre >
75
118
76
119
< p > You can modify this behavor with -update or -overwrite. Both options are
77
- order dependant (e.g . not associative, A update B does
120
+ order dependant (i.e . not associative, A update B does
78
121
not necessarily equal B update A).</ p >
79
122
80
123
< ul >
@@ -84,7 +127,7 @@ <h3>Joining two JSON objects (maps)</h3>
84
127
85
128
< p > Running</ p >
86
129
87
- < pre > < code class ="language-shell "> jsonjoin -update person.json profile.json
130
+ < pre > < code class ="language-shell "> jsonjoin -create - update person.json profile.json
88
131
</ code > </ pre >
89
132
90
133
< p > would yield</ p >
@@ -95,7 +138,7 @@ <h3>Joining two JSON objects (maps)</h3>
95
138
96
139
< p > Running</ p >
97
140
98
- < pre > < code class ="language-shell "> jsonjoin -update profile.json person.json
141
+ < pre > < code class ="language-shell "> jsonjoin -create - update profile.json person.json
99
142
</ code > </ pre >
100
143
101
144
< p > would yield</ p >
@@ -107,7 +150,7 @@ <h3>Joining two JSON objects (maps)</h3>
107
150
108
151
< p > Running</ p >
109
152
110
- < pre > < code class ="language-shell "> jsonjoin -overwrite person.json profile.json
153
+ < pre > < code class ="language-shell "> jsonjoin -create - overwrite person.json profile.json
111
154
</ code > </ pre >
112
155
113
156
< p > would yield</ p >
@@ -116,7 +159,7 @@ <h3>Joining two JSON objects (maps)</h3>
116
159
"bio": "World renowned geophysist." }
117
160
</ code > </ pre >
118
161
119
- < p > jsonjoin v0.0.12 </ p >
162
+ < p > jsonjoin v0.0.13 </ p >
120
163
121
164
</ section >
122
165
0 commit comments