Re: json results parsing

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Charles Cui <charles(dot)cui1984(at)gmail(dot)com>
Cc: Aleksander Alekseev <a(dot)alekseev(at)postgrespro(dot)ru>, Aleksandr Parfenov <a(dot)parfenov(at)postgrespro(dot)ru>, Anastasia Lubennikova <a(dot)lubennikova(at)postgrespro(dot)ru>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: json results parsing
Date: 2018-05-31 03:32:53
Message-ID: 20180531033253.GA1161@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, May 30, 2018 at 08:16:18PM -0700, Charles Cui wrote:
> Basically, I want to call these json API inside a plugin, and the return
> value for these APIs are Datum. I am wondering how to parse a set of json
> results from Datum in postgresql? Seems the helper functions I am aware of
> are only for simple types. Are there any examples to demonstrate the best
> practice of how to do that?

When it comes to the manipulation of data which uses a given data type,
you may want to look at how the input and output functions of this data
type work to understand how they can be fetched and saved. In the case
of json, that would be looking at respectively json_in and json_out.
Each type (and its array representation) has its own row within the
system catalog pg_type, where the input function is marked with
typinput, and the output as typoutput.

I hope that helps.
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Gierth 2018-05-31 06:00:28 Re: json results parsing
Previous Message Euler Taveira 2018-05-31 03:25:10 Re: ALTER CONSTRAINT change action