@@ -188,7 +188,7 @@ datum_to_json_internal(Datum val, bool is_null, StringInfo result,
188
188
189
189
if (is_null )
190
190
{
191
- appendStringInfoString (result , "null" );
191
+ appendBinaryStringInfo (result , "null" , strlen ( "null" ) );
192
192
return ;
193
193
}
194
194
@@ -210,11 +210,14 @@ datum_to_json_internal(Datum val, bool is_null, StringInfo result,
210
210
composite_to_json (val , result , false);
211
211
break ;
212
212
case JSONTYPE_BOOL :
213
- outputstr = DatumGetBool (val ) ? "true" : "false" ;
214
213
if (key_scalar )
215
- escape_json (result , outputstr );
214
+ appendStringInfoChar (result , '"' );
215
+ if (DatumGetBool (val ))
216
+ appendBinaryStringInfo (result , "true" , strlen ("true" ));
216
217
else
217
- appendStringInfoString (result , outputstr );
218
+ appendBinaryStringInfo (result , "false" , strlen ("false" ));
219
+ if (key_scalar )
220
+ appendStringInfoChar (result , '"' );
218
221
break ;
219
222
case JSONTYPE_NUMERIC :
220
223
outputstr = OidOutputFunctionCall (outfuncoid , val );
@@ -277,9 +280,8 @@ datum_to_json_internal(Datum val, bool is_null, StringInfo result,
277
280
case JSONTYPE_CAST :
278
281
/* outfuncoid refers to a cast function, not an output function */
279
282
jsontext = DatumGetTextPP (OidFunctionCall1 (outfuncoid , val ));
280
- outputstr = text_to_cstring (jsontext );
281
- appendStringInfoString (result , outputstr );
282
- pfree (outputstr );
283
+ appendBinaryStringInfo (result , VARDATA_ANY (jsontext ),
284
+ VARSIZE_ANY_EXHDR (jsontext ));
283
285
pfree (jsontext );
284
286
break ;
285
287
default :
0 commit comments