ECC-635: bufr_dump (JSON): should show missing value of string key as 'null'

This commit is contained in:
Shahram Najm 2018-02-16 18:29:12 +00:00
parent 7016e75eca
commit 94676e14a5
1 changed files with 6 additions and 1 deletions

View File

@ -405,6 +405,7 @@ static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
char *value = NULL;
char *p = NULL;
size_t size = 0;
int is_missing = 0;
grib_context* c = NULL;
int err = _grib_get_string_length(a,&size);
@ -427,6 +428,9 @@ static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
err = grib_unpack_string(a,value,&size);
p=value;
if (grib_is_missing_string(a,(unsigned char *)value,size)) {
is_missing = 1;
}
while(*p) { if(!isprint(*p)) *p = '.'; p++; }
@ -438,7 +442,8 @@ static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment)
fprintf(self->dumper.out,"\n%-*s",depth," ");
fprintf(self->dumper.out,"\"value\" : ");
}
fprintf(self->dumper.out,"\"%s\"",value);
if (is_missing) fprintf(self->dumper.out,"%s", "null");
else fprintf(self->dumper.out,"\"%s\"",value);
/* if (a->attributes[0]) fprintf(self->dumper.out,","); */