<p>I have a configMap which I'm trying to template. I have this  json value in my values.yaml file and in my configmap template I'm trying to get it as is via this command.</p>
<p>Is there a way how to parse the json value and it would return a clean json value which i can apply into my kubernetes cluster. Thanks a lot</p>
<pre><code>configmap.yaml
data: {{ .Values.config | toJson | quote }}

values.yaml
instance-0.json: |-
   {
     &quot;name&quot;: nameofserver,
     &quot;connectionType&quot;: &quot;STANDALONE&quot;,
     &quot;host&quot;: &quot;IP&quot;,
     &quot;port&quot;: 6379,
     &quot;username&quot;: &quot;&quot;,
     &quot;password&quot;: &quot;&quot;,
     &quot;tls&quot;: {
         &quot;useTls&quot;: false,
         &quot;verifyServerCert&quot;: true,
         &quot;clientAuth&quot;: false
     }

Result:

data: &quot;{\&quot;instance-0.json\&quot;:\&quot;{\\n  \\\&quot;name\\\&quot;: \\\&quot;nameofserver\\\&quot;,\\n  \\\&quot;connectionType\\\&quot;: \\\&quot;STANDALONE\\\&quot;,\\n  \\\&quot;host\\\&quot;: \\\&quot;IP\\\&quot;,\\n  \\\&quot;port\\\&quot;: 6379,\\n  \\\&quot;username\\\&quot;: \\\&quot;\\\&quot;,\\n  \\\&quot;password\\\&quot;: \\\&quot;\\\&quot;,\\n  \\\&quot;tls\\\&quot;: {\\n      \\\&quot;useTls\\\&quot;: false,\\n      \\\&quot;verifyServerCert\\\&quot;: true,\\n      \\\&quot;clientAuth\\\&quot;: false\\n  }\&quot;}&quot;



</code></pre>
<p>I tried the above and expected that it returns a clean Json file</p>

drowzee
<p>values.yaml</p>
<pre class="lang-yaml prettyprint-override"><code>config: 
  instance-0.json: |-
    {
      &quot;name&quot;: nameofserver,
      &quot;connectionType&quot;: &quot;STANDALONE&quot;,
      &quot;host&quot;: &quot;IP&quot;,
      &quot;port&quot;: 6379,
      &quot;username&quot;: &quot;&quot;,
      &quot;password&quot;: &quot;&quot;,
      &quot;tls&quot;: {
          &quot;useTls&quot;: false,
          &quot;verifyServerCert&quot;: true,
          &quot;clientAuth&quot;: false
      }
</code></pre>
<p>cm.yaml</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: test
data: 
  {{- toYaml .Values.config | nindent 2 }}
</code></pre>
<p>output</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: test
data:
  instance-0.json: |-
    {
      &quot;name&quot;: nameofserver,
      &quot;connectionType&quot;: &quot;STANDALONE&quot;,
      &quot;host&quot;: &quot;IP&quot;,
      &quot;port&quot;: 6379,
      &quot;username&quot;: &quot;&quot;,
      &quot;password&quot;: &quot;&quot;,
      &quot;tls&quot;: {
          &quot;useTls&quot;: false,
          &quot;verifyServerCert&quot;: true,
          &quot;clientAuth&quot;: false
      }
</code></pre>
