title: Convert environment variables into a json file
body: <p>I am trying to find a way to feed configuration settings into my SPA application that is running in a container.</p>
  <p>My current plan is to pass in the configuration as environment variables.  Then on container startup, generate a json file from those environment variables to pass to the browser (along with the SPA app).</p>
  <p>I am planning to format my environment variables like this:</p>
  <pre>
  Env Variable Name:  Security:ClientId 
  Env Variable Value: 123456
  
  Env Variable Name:  Security:clientSecret
  Env Variable Value: abcdefg
  
  Env Variable Name:  AppSettings:Environment
  Env Variable Value: Dev
  </pre>
  <p>That will convert into:</p>
  <pre><code>{
    &quot;AppSettings&quot;: {
      &quot;Environment&quot;: &quot;Dev&quot;,
    },
    &quot;Security&quot;: {
      &quot;ClientId&quot;: &quot;123456&quot;,
      &quot;ClientSecret&quot;: &quot;abcdefg&quot;
    }
  }
  </code></pre>
  <p>I am fairly inexperienced at shell scripting, but this has to be done in a shell script so it can run in a Linux container.</p>
  <p>I have read of <code>jq</code>, and it seems to be the way to interact with Json files in a shell script.  But they all seem to want you to start with an existing json file that you will be transforming to a different json file.</p>
  <p><strong>How do I create a new json file from a list of key value pairs, with sub sections and using <code>jq</code> (or something else in a shell script)?</strong></p>