Reputation: 657
Given code like this:
JSON_OBJECT_AGG(company_id, JSON_BUILD_OBJECT(...)) AS company_info
I get JSON output like this:
{"1234": {...}, "4321": {...}}
How do I get it to return the keys as ints instead of strings, so I'd get this:
{1234: {...}, 4321: {...}}
The company_id
already is an INTEGER
to begin with, and I haven't found a way to tell JSON_OBJECT_AGG to keep it that way.
Upvotes: 1
Views: 520
Reputation: 181
This is not possible. The JSON specification states that all keys must be string.
Converting the keys to integers should be done in your application logic after deserializing the returned database result.
Upvotes: 4