title: Update bool value in a jsonb column - jsonb_set
body: <p>With the following json exemple:</p>
  <pre><code>{
    &quot;red&quot;: false,
    &quot;blue&quot;: false,
    &quot;yellow&quot;: false
  }
  </code></pre>
  <p>I have to update one of the elements to true and the expected result is:</p>
  <pre><code>{
    &quot;red&quot;: false,
    &quot;blue&quot;: false,
    &quot;yellow&quot;: true
  }
  </code></pre>
  <p>First, i tried to update this way:</p>
  <pre><code>UPDATE table_name
     SET jsonb_column_name = jsonb_set(jsonb_column_name, '{yellow}', ('&quot;true&quot;')::jsonb, true) 
  </code></pre>
  <p>But the result was</p>
  <pre><code>{
    &quot;red&quot;: false,
    &quot;blue&quot;: false,
    &quot;yellow&quot;: &quot;true&quot;
  }
  </code></pre>
  <p>not what i want, its a string, not bool</p>
  <p>Also tried:</p>
  <pre><code>UPDATE table_name
     SET jsonb_column_name = jsonb_set(jsonb_column_name, '{yellow}', true, true)
  </code></pre>
  <p>But i got an error, that makes sense, the 3rd parameter has to be jsonb</p>
  <pre><code>SQL Error [42883]: ERROR: function jsonb_set(jsonb, unknown, boolean, boolean) does not exist
    Hint: No function matches the given name and argument types. You might need to add explicit type casts.
  </code></pre>
  <p>And i cannot make true::jsonb because bool cant be cast to jsonb:</p>
  <pre><code>SQL Error [42846]: ERROR: cannot cast type boolean to jsonb
  </code></pre>
  <p>Ther is another way to do this? no need to use jsonb_set, i think i can user str_replace an then convert to jsonb but i don't know if its safe</p>