Commit 243ee266 authored by Andrew Dunstan's avatar Andrew Dunstan

Reindent json.c and jsonfuncs.c.

This will help in preparation of clean patches for upcoming
json work.
parent 6c36f383
......@@ -751,11 +751,12 @@ json_lex_string(JsonLexContext *lex)
report_json_context(lex)));
/*
* For UTF8, replace the escape sequence by the actual utf8
* character in lex->strval. Do this also for other encodings
* if the escape designates an ASCII character, otherwise
* raise an error. We don't ever unescape a \u0000, since that
* would result in an impermissible nul byte.
* For UTF8, replace the escape sequence by the actual
* utf8 character in lex->strval. Do this also for other
* encodings if the escape designates an ASCII character,
* otherwise raise an error. We don't ever unescape a
* \u0000, since that would result in an impermissible nul
* byte.
*/
if (ch == 0)
......@@ -771,8 +772,9 @@ json_lex_string(JsonLexContext *lex)
else if (ch <= 0x007f)
{
/*
* This is the only way to designate things like a form feed
* character in JSON, so it's useful in all encodings.
* This is the only way to designate things like a
* form feed character in JSON, so it's useful in all
* encodings.
*/
appendStringInfoChar(lex->strval, (char) ch);
}
......@@ -1246,13 +1248,14 @@ datum_to_json(Datum val, bool is_null, StringInfo result,
break;
case TYPCATEGORY_NUMERIC:
outputstr = OidOutputFunctionCall(typoutputfunc, val);
/*
* Don't call escape_json here if it's a valid JSON number.
*/
dummy_lex.input = *outputstr == '-' ? outputstr + 1 : outputstr;
dummy_lex.input_length = strlen(dummy_lex.input);
json_lex_number(&dummy_lex, dummy_lex.input, &numeric_error);
if (! numeric_error)
if (!numeric_error)
appendStringInfoString(result, outputstr);
else
escape_json(result, outputstr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment