title: How do I modify fields inside the new PostgreSQL JSON datatype?
body: <p>With postgresql 9.3 I can <code>SELECT</code> specific fields of a JSON data type, but how do you modify them using <code>UPDATE</code>? I can't find any examples of this in the postgresql documentation, or anywhere online. I have tried the obvious:</p>
  <pre class="lang-sql prettyprint-override"><code>postgres=# create table test (data json);
  CREATE TABLE
  postgres=# insert into test (data) values ('{&quot;a&quot;:1,&quot;b&quot;:2}');
  INSERT 0 1
  postgres=# select data-&gt;'a' from test where data-&gt;&gt;'b' = '2';
   ?column?
  ----------
   1
  (1 row)
  postgres=# update test set data-&gt;'a' = to_json(5) where data-&gt;&gt;'b' = '2';
  ERROR:  syntax error at or near &quot;-&gt;&quot;
  LINE 1: update test set data-&gt;'a' = to_json(5) where data-&gt;&gt;'b' = '2...
  </code></pre>