OSDN Git Service

Allow handled properties not to have a short name
authorKyotaro Horiguchi <horiguchi.kyotaro@lab.ntt.co.jp>
Fri, 26 Aug 2016 01:22:10 +0000 (10:22 +0900)
committerKyotaro Horiguchi <horiguchi.kyotaro@lab.ntt.co.jp>
Fri, 26 Aug 2016 07:10:10 +0000 (16:10 +0900)
Shorten a json representaion allows the properties that the parser
doesn't knonw to be left unshortened. This is applicable to other
properties that the parser knows *but* don't shorten
intentionally. This is convenient some properties to be handled but
rarely seen.

pgsp_json.c

index a7dc881..0b907de 100644 (file)
@@ -701,9 +701,14 @@ json_ofstart(void *state, char *fname, bool isnull)
        if (ctx->mode == PGSP_JSON_INFLATE)
                appendStringInfoSpaces(ctx->dest, ctx->level * INDENT_STEP);
 
+       /*
+        * We intentionally let some property names not have a short name. Use long
+        * name for the cases.
+        */
        if (!p || !p->longname)
                fn = fname;
-       else if (ctx->mode == PGSP_JSON_INFLATE)
+       else if (ctx->mode == PGSP_JSON_INFLATE ||
+                        !(p->shortname && p->shortname[0]))
                fn = p->longname;
        else
                fn = p->shortname;