Postgresql: Modify one value inside of a nested json column I have a json column called &quot;Parameters&quot; in a &quot;Assets&quot; table. The jsons are nested and have the following structure:
{
&quot;params1&quot;: {&quot;k&quot;: 1.1, &quot;efficiency&quot;: 0.7}, 
&quot;params2&quot;: {&quot;k&quot;: 1.9, &quot;C_max&quot;: 100.0, &quot;C_min&quot;: 10.0}
}

I would like to update only one value &quot;k&quot; in &quot;params2&quot; and keep the rest of the values unchanged. I tried with the following code:
update &quot;Assets&quot; 
set &quot;Parameters&quot; = &quot;Parameters&quot;::jsonb || '{&quot;params2&quot;:{&quot;k&quot;:2.2}}'::jsonb
where &quot;Id&quot; = 185;

This results in
{
&quot;params1&quot;: {&quot;k&quot;: 1.1, &quot;efficiency&quot;: 0.7}, 
&quot;params2&quot;: {&quot;k&quot;: 2.2}
}

So the rest of the parameters in &quot;params2&quot; are dropped which is not desired. What would be a way to modify &quot;k&quot; and leave the rest as it is?
You are looking for jsonb_set()
update &quot;Assets&quot; 
  set &quot;Parameters&quot; = jsonb_set(&quot;Parameters&quot;::jsonb, '{params2, k}', to_jsonb(2.2))
where ...