title: passing array as key pair in json format to function pgsql
body: <p>I have created a function that accepts a json. Here is the query</p>
  <pre><code>CREATE OR REPLACE FUNCTION public.data_get(
      data json)
      RETURNS SETOF json 
      LANGUAGE 'plpgsql'
      COST 100
      VOLATILE PARALLEL UNSAFE
      ROWS 1000
  
  AS $BODY$
  DECLARE
          declare _text text;
          
      BEGIN
      -- get fields data from json - https://www.postgresql.org/docs/9.3/functions-json.html
      _text = data::json#&gt;&gt;'{text}';
  </code></pre>
  <p>and this is how i call this function</p>
  <pre><code>select * from data_get ('{&quot;text&quot;:&quot;my&quot;}'::json) as info; 
  </code></pre>
  <p>and this works fine</p>
  <p>now i want to pass the array element so i added the variables like this</p>
  <pre><code>DECLARE
          declare 
             _text text;
             _ids bigint[];
  </code></pre>
  <p>and accessed from json like this</p>
  <pre><code>_ids = data::json#&gt;&gt;'{ids}';
  </code></pre>
  <p>but when i call this function</p>
  <pre><code>select * from data_get ('{&quot;text&quot;:&quot;&quot;,&quot;ids&quot;:[1]}'::json) as info;
  </code></pre>
  <p>it shows</p>
  <pre><code>ERROR:  malformed array literal: &quot;[1]&quot;
  DETAIL:  Missing &quot;=&quot; after array dimensions.
  CONTEXT:  PL/pgSQL function posts_get(json) line 18 at assignment
  SQL state: 22P02
  </code></pre>
  <p>how can i call this function?</p>