425{
426 char *outputstr;
427 text *jsontext;
428
429 check_stack_depth();
430
431
432 Assert(!(key_scalar && is_null));
433
434 if (is_null)
435 {
436 appendStringInfoString(
result,
"null");
437 return;
438 }
439
440 if (key_scalar &&
445 ereport(ERROR,
446 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
447 errmsg("key value must be scalar, not array, composite, or json")));
448
449 switch (tcategory)
450 {
453 break;
456 break;
458 outputstr = DatumGetBool(val) ? "true" : "false";
459 if (key_scalar)
460 escape_json(
result, outputstr);
461 else
462 appendStringInfoString(
result, outputstr);
463 break;
465 outputstr = OidOutputFunctionCall(outfuncoid, val);
466
467
468
469
470
471 if (!key_scalar && IsValidJsonNumber(outputstr, strlen(outputstr)))
472 appendStringInfoString(
result, outputstr);
473 else
474 escape_json(
result, outputstr);
475 pfree(outputstr);
476 break;
478 {
479 char buf[MAXDATELEN + 1];
480
482 appendStringInfo(
result,
"\"%s\"", buf);
483 }
484 break;
486 {
487 char buf[MAXDATELEN + 1];
488
490 appendStringInfo(
result,
"\"%s\"", buf);
491 }
492 break;
494 {
495 char buf[MAXDATELEN + 1];
496
498 appendStringInfo(
result,
"\"%s\"", buf);
499 }
500 break;
502
503 outputstr = OidOutputFunctionCall(outfuncoid, val);
504 appendStringInfoString(
result, outputstr);
505 pfree(outputstr);
506 break;
508
509 jsontext = DatumGetTextPP(OidFunctionCall1(outfuncoid, val));
510 outputstr = text_to_cstring(jsontext);
511 appendStringInfoString(
result, outputstr);
512 pfree(outputstr);
513 pfree(jsontext);
514 break;
515 default:
516 outputstr = OidOutputFunctionCall(outfuncoid, val);
517 escape_json(
result, outputstr);
518 pfree(outputstr);
519 break;
520 }
521}
char result[OUT_DOUBLE_BUFFER_SIZE]
static char * postgis_JsonEncodeDateTime(char *buf, Datum value, Oid typid)
static void composite_to_json(Datum composite, StringInfo result, bool use_line_feeds)
static void array_to_json_internal(Datum array, StringInfo result, bool use_line_feeds)