title: MySQL JSON type insert and select using JDBC drivers
body: <p>I am reading and writing mysql JSON type using JDBC driver and <code>ResultSet</code>. How do I fetch the JSON type from <code>ResultSet</code> as string JSON to be used in java program ?</p>
  
  <pre><code>mysql&gt; set names UTF8MB4; // so that json values can be inserted using jdbc driver otherwise it was complaining of binary type
  </code></pre>
  
  <p>Java code (pseudo code):</p>
  
  <pre class="lang-java prettyprint-override"><code>String myjsonString = "{x: y}"; // assume this is proper
  conn.getPreparedStatement("insert into col_json values (myjsonString)");
  
  
  rs = conn.getStatement("select col_json from table_json_test");
  
  String myorig_json = rs.getString("col_json");
  </code></pre>
  
  <p><code>myorig_json</code> is coming as a string like this:</p>
  
  <pre><code>"base64:type15:rO0ABXNyABdqYXZhLnV0aWwuTGlua2VkSGFzaE1hcDTATlwQbMD7AgABWgALYWNjZXNzT3JkZXJ4
  cgARamF2YS51dGlsLkhhc2hNYXAFB9rBwxZg0QMAAkYACmxvYWRGYWN0b3JJAAl0aHJlc2hvbGR4
  cD9AAAAAAAAMdwgAAAAQAAAAAXQABXJlZmlkdAAgZWI3ODkzZWVjMDU5NGNhMjlhYjY1OTJjMjFj
  MjIwNWZ4AA=="
  </code></pre>
  
  <p>expected is <code>"{x: y}"</code></p>