PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ composite_to_json()

static void composite_to_json ( Datum  composite,
StringInfo  result,
bool  use_line_feeds 
)
static

Definition at line 574 of file lwgeom_out_geojson.c.

575{
576 HeapTupleHeader td;
577 Oid tupType;
578 int32 tupTypmod;
579 TupleDesc tupdesc;
580 HeapTupleData tmptup,
581 *tuple;
582 int i;
583 bool needsep = false;
584 const char *sep;
585
586 sep = use_line_feeds ? ",\n " : ",";
587
588 td = DatumGetHeapTupleHeader(composite);
589
590 /* Extract rowtype info and find a tupdesc */
591 tupType = HeapTupleHeaderGetTypeId(td);
592 tupTypmod = HeapTupleHeaderGetTypMod(td);
593 tupdesc = lookup_rowtype_tupdesc(tupType, tupTypmod);
594
595 /* Build a temporary HeapTuple control structure */
596 tmptup.t_len = HeapTupleHeaderGetDatumLength(td);
597 tmptup.t_data = td;
598 tuple = &tmptup;
599
600 appendStringInfoChar(result, '{');
601
602 for (i = 0; i < tupdesc->natts; i++)
603 {
604 Datum val;
605 bool isnull;
606 char *attname;
607 JsonTypeCategory tcategory;
608 Oid outfuncoid;
609 Form_pg_attribute att = TupleDescAttr(tupdesc, i);
610
611 if (att->attisdropped)
612 continue;
613
614 if (needsep)
615 appendStringInfoString(result, sep);
616 needsep = true;
617
618 attname = NameStr(att->attname);
619 escape_json(result, attname);
620 appendStringInfoChar(result, ':');
621
622 val = heap_getattr(tuple, i + 1, tupdesc, &isnull);
623
624 if (isnull)
625 {
626 tcategory = JSONTYPE_NULL;
627 outfuncoid = InvalidOid;
628 }
629 else
630 json_categorize_type(att->atttypid, &tcategory, &outfuncoid);
631
632 datum_to_json(val, isnull, result, tcategory, outfuncoid, false);
633 }
634
635 appendStringInfoChar(result, '}');
636 ReleaseTupleDesc(tupdesc);
637}
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
static void json_categorize_type(Oid typoid, JsonTypeCategory *tcategory, Oid *outfuncoid)
JsonTypeCategory
@ JSONTYPE_NULL
static void datum_to_json(Datum val, bool is_null, StringInfo result, JsonTypeCategory tcategory, Oid outfuncoid, bool key_scalar)
unsigned int int32
Definition shpopen.c:54

References datum_to_json(), json_categorize_type(), JSONTYPE_NULL, and result.

Referenced by datum_to_json().

Here is the call graph for this function:
Here is the caller graph for this function: