I am using the http extension in Postgresql, making a request, and getting a list of jsonb [{keys, values}] in a single column 'details' as a response.
It seems like there should be an easy way to create a new table from the keys and values.
Here is the request:
WITH sport_markets_api AS (
SELECT ((CONTENT::jsonb ->> 'data')::jsonb ->> 'sportMarkets')::jsonb AS details
FROM http_post(
'
https://api.thegraph.com/subgraphs/name/',
/>
'{"query": "{sportMarkets(first:2,skip:0,orderBy:timestamp,orderDirection:desc){id,timestamp,address,gameId,maturityDate,tags,isOpen,isResolved,isCanceled,finalResult,homeTeam,awayTeam }}"}'::text,
'application/json'))
I tried:
SELECT
jsonb_array_elements(details) ->> jsonb_object_keys(jsonb_array_elements(details))
FROM sport_markets_api
and was expecting a table with columns based on the keys.
How to Create a New Table from JSONB_ARRAY_ELEMENTS and JSONB_OBJECT_KEYS in Postgresql?
Programing Coderfunda
March 07, 2024
No comments
Related Posts:
An Overview Of How Livewire Workshttps://medium.com/@developer.olly/an-overview-of-how-livewire-works-85395746d10a submitted by /u/dev_olly [link] [comments]… Read More
APM vs. Application Performance Observability - What’s the DifferenceYou’ve likely heard the term Observability lately. There’s a fundamental change taking place in the Monitoring space, and Observability is behind it. … Read More
Lara Reserve: a package to add a reservation feature to the laravel frameworksubmitted by /u/shayanys [link] [comments]… Read More
Brainstorm Tests With PEST Todos 🔥Quickly brainstorm test requirements with Laravel and Pest PHP with this fire tip from Laracasts! The post Brainstorm Tests With PEST Todos 🔥 appe… Read More
How can I use Dependency Injection to pass Application() to ViewModel() using Hilt in Android Studio?I 'm using Hilt as Dependency Injection, I hope to DI class UIApp into class SoundViewModel, so I use fun provideUIApp(): UIApp {...} as the following… Read More
0 comments:
Post a Comment
Thanks