Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
json_array_elements: invalid input syntax for integer

I have the following sample data for demo:

Table:

create table tbl_json
(
   id json
);

Some values:

insert into tbl_json values('[{"id":1},{"id":2},{"id":3}]');

Query: Convert/cast id into integer from json column.

Tried:

select json_array_elements(id)->>'id'::int ids 
from tbl_json;

Getting an error:

ERROR: invalid input syntax for integer: "id"

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The ::int cast is applied to 'id' because it has a higher precedence.

select (json_array_elements(id)->>'id')::int ids 
from tbl_json;
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!