|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <title>Caltech Library's Digital Library Development Sandbox</title> |
| 5 | + <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'> |
| 6 | + <link rel="stylesheet" href="/css/site.css"> |
| 7 | +</head> |
| 8 | +<body> |
| 9 | +<header> |
| 10 | +<a href="http://library.caltech.edu"><img src="/assets/liblogo.gif" alt="Caltech Library logo"></a> |
| 11 | +</header> |
| 12 | +<nav> |
| 13 | +<ul> |
| 14 | +<li><a href="/">Home</a></li> |
| 15 | +<li><a href="../">up</a></li> |
| 16 | +<li><a href="./">Documentation</a></li> |
| 17 | +<li><a href="../how-to/">How To …</a></li> |
| 18 | +</ul> |
| 19 | + |
| 20 | +</nav> |
| 21 | + |
| 22 | +<section> |
| 23 | +<h1>USAGE</h1> |
| 24 | + |
| 25 | +<h2>jsonjoin [OPTIONS] JSON_FILE_1 JSON_FILE_2</h2> |
| 26 | + |
| 27 | +<h2>SYSNOPSIS</h2> |
| 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> |
| 32 | + |
| 33 | +<h2>OPTIONS</h2> |
| 34 | + |
| 35 | +<pre><code>-h display help |
| 36 | +-help display help |
| 37 | +-l display license |
| 38 | +-license display license |
| 39 | +-o output filename |
| 40 | +-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 |
| 43 | +-v display version |
| 44 | +-version display version |
| 45 | +</code></pre> |
| 46 | + |
| 47 | +<h2>EXAMPLES</h2> |
| 48 | + |
| 49 | +<h3>Joining two JSON objects (maps)</h3> |
| 50 | + |
| 51 | +<p>person.json containes</p> |
| 52 | + |
| 53 | +<pre><code class=" language-json" > {"name": "Doe, Jane", "email":" [email protected]", "age": 42} |
| 54 | +</code></pre> |
| 55 | + |
| 56 | +<p>profile.json containes</p> |
| 57 | + |
| 58 | +<pre><code class="language-json"> {"name": "Doe, Jane", "bio": "World renowned geophysist.", |
| 59 | + "email": " [email protected]"} |
| 60 | +</code></pre> |
| 61 | + |
| 62 | +<p>A simple join of person.json with profile.json</p> |
| 63 | + |
| 64 | +<pre><code class="language-shell"> jsonjoin person.json profile.json |
| 65 | +</code></pre> |
| 66 | + |
| 67 | +<p>would yeild</p> |
| 68 | + |
| 69 | +<pre><code class="language-json"> { |
| 70 | + "person": {"name": "Doe, Jane", "email":" [email protected]", "age": 42}, |
| 71 | + "profile": {"name": "Doe, Jane", "bio": "World renowned geophysist.", |
| 72 | + "email": " [email protected]"} |
| 73 | + } |
| 74 | +</code></pre> |
| 75 | + |
| 76 | +<p>You can modify this behavor with -add or -merge. Both options are |
| 77 | +order dependant (i.e. not guaranteed to be associative, A add B does |
| 78 | +not necessarily equal B add A).</p> |
| 79 | + |
| 80 | +<ul> |
| 81 | +<li>-update will add unique key/values from the second object to the first object</li> |
| 82 | +<li>-overwrite replace key/values in first object one with second objects’</li> |
| 83 | +</ul> |
| 84 | + |
| 85 | +<p>Running</p> |
| 86 | + |
| 87 | +<pre><code class="language-shell"> jsonjoin -update person.json profile.json |
| 88 | +</code></pre> |
| 89 | + |
| 90 | +<p>would yield</p> |
| 91 | + |
| 92 | +<pre><code class=" language-json" > { "name": "Doe, Jane", "email":" [email protected]", "age": 42, |
| 93 | + "bio": "World renowned geophysist." } |
| 94 | +</code></pre> |
| 95 | + |
| 96 | +<p>Running</p> |
| 97 | + |
| 98 | +<pre><code class="language-shell"> jsonjoin -update profile.json person.json |
| 99 | +</code></pre> |
| 100 | + |
| 101 | +<p>would yield</p> |
| 102 | + |
| 103 | +<pre><code class="language-json"> { "name": "Doe, Jane", "age": 42, |
| 104 | + "bio": "World renowned geophysist.", |
| 105 | + "email": " [email protected]" } |
| 106 | +</code></pre> |
| 107 | + |
| 108 | +<p>Running</p> |
| 109 | + |
| 110 | +<pre><code class="language-shell"> jsonjoin -overwrite person.json profile.json |
| 111 | +</code></pre> |
| 112 | + |
| 113 | +<p>would yield</p> |
| 114 | + |
| 115 | +<pre><code class=" language-json" > { "name": "Doe, Jane", "email":" [email protected]", "age": 42, |
| 116 | + "bio": "World renowned geophysist." } |
| 117 | +</code></pre> |
| 118 | + |
| 119 | +<p>jsonjoin v0.0.12</p> |
| 120 | + |
| 121 | +</section> |
| 122 | + |
| 123 | +<footer> |
| 124 | +<span><h1><A href="http://caltech.edu">Caltech</a></h1></span> |
| 125 | +<span>© 2017 <a href="https://www.library.caltech.edu/copyright">Caltech library</a></span> |
| 126 | +<address>1200 E California Blvd, Mail Code 1-32, Pasadena, CA 91125-3200</address> |
| 127 | +<span>Phone: <a href="tel:+1-626-395-3405">(626)395-3405</a></span> |
| 128 | +<span><a href=" mailto:[email protected]" >Email Us </a></span> |
| 129 | +<a class="cl-hide" href="sitemap.xml">Site Map</a> |
| 130 | +</footer> |
| 131 | +</body> |
| 132 | +</html> |
0 commit comments