@@ -751,11 +751,12 @@ json_lex_string(JsonLexContext *lex)
751751 report_json_context (lex )));
752752
753753 /*
754- * For UTF8, replace the escape sequence by the actual utf8
755- * character in lex->strval. Do this also for other encodings
756- * if the escape designates an ASCII character, otherwise
757- * raise an error. We don't ever unescape a \u0000, since that
758- * would result in an impermissible nul byte.
754+ * For UTF8, replace the escape sequence by the actual
755+ * utf8 character in lex->strval. Do this also for other
756+ * encodings if the escape designates an ASCII character,
757+ * otherwise raise an error. We don't ever unescape a
758+ * \u0000, since that would result in an impermissible nul
759+ * byte.
759760 */
760761
761762 if (ch == 0 )
@@ -771,8 +772,9 @@ json_lex_string(JsonLexContext *lex)
771772 else if (ch <= 0x007f )
772773 {
773774 /*
774- * This is the only way to designate things like a form feed
775- * character in JSON, so it's useful in all encodings.
775+ * This is the only way to designate things like a
776+ * form feed character in JSON, so it's useful in all
777+ * encodings.
776778 */
777779 appendStringInfoChar (lex -> strval , (char ) ch );
778780 }
@@ -866,7 +868,7 @@ json_lex_string(JsonLexContext *lex)
866868 ereport (ERROR ,
867869 (errcode (ERRCODE_INVALID_TEXT_REPRESENTATION ),
868870 errmsg ("invalid input syntax for type json" ),
869- errdetail ("Unicode low surrogate must follow a high surrogate." ),
871+ errdetail ("Unicode low surrogate must follow a high surrogate." ),
870872 report_json_context (lex )));
871873
872874 /* Hooray, we found the end of the string! */
@@ -1221,7 +1223,7 @@ datum_to_json(Datum val, bool is_null, StringInfo result,
12211223{
12221224 char * outputstr ;
12231225 text * jsontext ;
1224- bool numeric_error ;
1226+ bool numeric_error ;
12251227 JsonLexContext dummy_lex ;
12261228
12271229 if (is_null )
@@ -1246,13 +1248,14 @@ datum_to_json(Datum val, bool is_null, StringInfo result,
12461248 break ;
12471249 case TYPCATEGORY_NUMERIC :
12481250 outputstr = OidOutputFunctionCall (typoutputfunc , val );
1251+
12491252 /*
12501253 * Don't call escape_json here if it's a valid JSON number.
12511254 */
12521255 dummy_lex .input = * outputstr == '-' ? outputstr + 1 : outputstr ;
12531256 dummy_lex .input_length = strlen (dummy_lex .input );
12541257 json_lex_number (& dummy_lex , dummy_lex .input , & numeric_error );
1255- if (! numeric_error )
1258+ if (!numeric_error )
12561259 appendStringInfoString (result , outputstr );
12571260 else
12581261 escape_json (result , outputstr );
@@ -1808,34 +1811,34 @@ json_typeof(PG_FUNCTION_ARGS)
18081811
18091812 JsonLexContext * lex = makeJsonLexContext (json , false);
18101813 JsonTokenType tok ;
1811- char * type ;
1814+ char * type ;
18121815
18131816 /* Lex exactly one token from the input and check its type. */
18141817 json_lex (lex );
18151818 tok = lex_peek (lex );
18161819 switch (tok )
18171820 {
1818- case JSON_TOKEN_OBJECT_START :
1819- type = "object" ;
1820- break ;
1821- case JSON_TOKEN_ARRAY_START :
1822- type = "array" ;
1823- break ;
1824- case JSON_TOKEN_STRING :
1825- type = "string" ;
1826- break ;
1827- case JSON_TOKEN_NUMBER :
1828- type = "number" ;
1829- break ;
1830- case JSON_TOKEN_TRUE :
1831- case JSON_TOKEN_FALSE :
1832- type = "boolean" ;
1833- break ;
1834- case JSON_TOKEN_NULL :
1835- type = "null" ;
1836- break ;
1837- default :
1838- elog (ERROR , "unexpected json token: %d" , tok );
1821+ case JSON_TOKEN_OBJECT_START :
1822+ type = "object" ;
1823+ break ;
1824+ case JSON_TOKEN_ARRAY_START :
1825+ type = "array" ;
1826+ break ;
1827+ case JSON_TOKEN_STRING :
1828+ type = "string" ;
1829+ break ;
1830+ case JSON_TOKEN_NUMBER :
1831+ type = "number" ;
1832+ break ;
1833+ case JSON_TOKEN_TRUE :
1834+ case JSON_TOKEN_FALSE :
1835+ type = "boolean" ;
1836+ break ;
1837+ case JSON_TOKEN_NULL :
1838+ type = "null" ;
1839+ break ;
1840+ default :
1841+ elog (ERROR , "unexpected json token: %d" , tok );
18391842 }
18401843
18411844 PG_RETURN_TEXT_P (cstring_to_text (type ));
0 commit comments