how do I convert text to jsonB : <p>What is the proper way to convert any text (or varchar) to <code>jsonB</code> type in Postgres (version 9.6) ?</p>

<p>For example, here I am using two methods and I am getting different results:</p>

<p>Method 1:</p>

<pre><code>dev=# select '[{"field":15,"operator":0,"value":"1"},{"field":15,"operator":0,"value":"2"},55]'::jsonb;
                                            jsonb                                             
----------------------------------------------------------------------------------------------
 [{"field": 15, "value": "1", "operator": 0}, {"field": 15, "value": "2", "operator": 0}, 55]
(1 row)
</code></pre>

<p>Method 2 , which doesn't produce the desired results, btw:</p>

<pre><code>dev=# select to_jsonb('[{"field":15,"operator":0,"value":"1"},{"field":15,"operator":0,"value":"2"},55]'::text);
                                              to_jsonb                                              
----------------------------------------------------------------------------------------------------
 "[{\"field\":15,\"operator\":0,\"value\":\"1\"},{\"field\":15,\"operator\":0,\"value\":\"2\"},55]"
(1 row)

dev=# 
</code></pre>

<p>Here, it was converted to a string, not an array.
Why doesn't the second method creates an array ?</p>
