title: MySQL JSON_OBJECT() with some fields already containing JSON String
body: <p>How to get a JSON_OBJECT() of 3 columns whose <strong>some contains already a JSON format string</strong>. </p>
  
  <p>Here is my example with <code>info</code> field that contains a json string, so all this object is escaped :</p>
  
  <pre><code>SELECT 
      T1.id, 
      CONCAT(
          '{"elements": [',
          GROUP_CONCAT(
              JSON_OBJECT(
                  'type',  T2.`type`,
                  'data',  T2.`data`,
                  'info',  T2.`info`  &lt;&lt;-- JSON stored string in varchar(100)
              )
          ),
          ']}'
      ) AS `elements`,
  FROM `table` T1
  INNER JOIN `table2` T2
      ON T1.`id` = T2.`fk_t1_id`
  GROUP BY T1.`id`
  </code></pre>
  
  <p>Maybe, use the new storage functions for JSON format will be better, but I didn't test it yet. What do you think ?</p>