 +			break;
 +		case T_BitString:
 +			/* internal representation already has leading 'b' */
-+			appendStringInfoString(str, value->val.str);
++			_outToken(str, value->val.str);
 +			break;
 +		case T_Null:
 +			/* this is seen only within A_Const, not in transformed trees */

+static void
+_outToken(StringInfo str, const char *s)
+{
+	if (s == NULL || *s == '\0')
+	{
+		appendStringInfoString(str, "null");
+		return;

index 0000000..eaded0f
--- /dev/null
+++ b/src/backend/nodes/outfuncs_json.c
@@ -0,0 +1,1036 @@
+/*-------------------------------------------------------------------------
+ *
+ * outfuncs_json.c
