Skip to content

Commit 344b414

Browse files
committed
Quick Save
1 parent b715e8e commit 344b414

File tree

1 file changed

+60
-17
lines changed

1 file changed

+60
-17
lines changed

docs/jsonjoin.html

+60-17
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,52 @@
2222
<section>
2323
<h1>USAGE</h1>
2424

25-
<h2>jsonjoin [OPTIONS] JSON_FILE_1 JSON_FILE_2</h2>
25+
<h2>jsonjoin [OPTIONS] JSON_FILE_1 [JSON_FILE_2 &hellip;]</h2>
2626

2727
<h2>SYSNOPSIS</h2>
2828

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&rsquo;t support a JSON array as the root JSON object.</p>
3249

3350
<h2>OPTIONS</h2>
3451

35-
<pre><code>-h display help
52+
<pre><code>-create create an empty root object, {}
53+
-h display help
3654
-help display help
55+
-i input filename (for root object)
56+
-input input filename (for root object)
3757
-l display license
3858
-license display license
3959
-o output filename
4060
-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
4363
-v display version
4464
-version display version
4565
</code></pre>
4666

4767
<h2>EXAMPLES</h2>
4868

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>
5071

5172
<p>person.json containes</p>
5273

@@ -59,22 +80,44 @@ <h3>Joining two JSON objects (maps)</h3>
5980
&quot;email&quot;: &quot;[email protected]&quot; }
6081
</code></pre>
6182

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+
&quot;person&quot;: { &quot;name&quot;: &quot;Doe, Jane&quot;, &quot;email&quot;:&quot;[email protected]&quot;,
93+
&quot;age&quot;: 42},
94+
&quot;profile&quot;: { &quot;name&quot;: &quot;Doe, Jane&quot;, &quot;bio&quot;: &quot;World renowned geophysist.&quot;,
95+
&quot;email&quot;: &quot;[email protected]&quot; }
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>
63106

64-
<pre><code class="language-shell"> jsonjoin person.json profile.json
107+
<pre><code class="language-shell"> jsonjoin -i person.json profile.json
65108
</code></pre>
66109

67-
<p>would yeild</p>
110+
<p>this yields an object like</p>
68111

69112
<pre><code class="language-json"> {
70-
&quot;person&quot;: { &quot;name&quot;: &quot;Doe, Jane&quot;, &quot;email&quot;:&quot;[email protected]&quot;, &quot;age&quot;: 42},
113+
&quot;name&quot;: &quot;Doe, Jane&quot;, &quot;email&quot;:&quot;[email protected]&quot;, &quot;age&quot;: 42,
71114
&quot;profile&quot;: { &quot;name&quot;: &quot;Doe, Jane&quot;, &quot;bio&quot;: &quot;World renowned geophysist.&quot;,
72115
&quot;email&quot;: &quot;[email protected]&quot; }
73116
}
74117
</code></pre>
75118

76119
<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
78121
not necessarily equal B update A).</p>
79122

80123
<ul>
@@ -84,7 +127,7 @@ <h3>Joining two JSON objects (maps)</h3>
84127

85128
<p>Running</p>
86129

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
88131
</code></pre>
89132

90133
<p>would yield</p>
@@ -95,7 +138,7 @@ <h3>Joining two JSON objects (maps)</h3>
95138

96139
<p>Running</p>
97140

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
99142
</code></pre>
100143

101144
<p>would yield</p>
@@ -107,7 +150,7 @@ <h3>Joining two JSON objects (maps)</h3>
107150

108151
<p>Running</p>
109152

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
111154
</code></pre>
112155

113156
<p>would yield</p>
@@ -116,7 +159,7 @@ <h3>Joining two JSON objects (maps)</h3>
116159
&quot;bio&quot;: &quot;World renowned geophysist.&quot; }
117160
</code></pre>
118161

119-
<p>jsonjoin v0.0.12</p>
162+
<p>jsonjoin v0.0.13</p>
120163

121164
</section>
122165

0 commit comments

Comments
 (0)