ncbi / sra-tools

SRA Tools
Other
1.12k stars 246 forks source link

vdb-dump -f json # produces invalid JSON #246

Closed tseemann closed 1 year ago

tseemann commented 4 years ago
% vdb-dump -f json  --info  SRR060042  > foo.json

{
"acc":"SRR060042",
"path":"https://sra-download.ncbi.nlm.nih.gov/traces/sra6/SRR/000058/SRR060042",
"size":7253676923,
"type":"Table",
"platf":"SRA_PLATFORM_ILLUMINA",
"SEQ":58925865,
"SCHEMA":"NCBI:SRA:Illumina:tbl:phred:v2#1.0.4",
"FORMATTER":{
"NAME":"internal",
"VERS":"1.0.0",
},
"LOADER":{
"NAME":"fastq-load",
"VERS":"1.0.20",
"TOOLDATE":"May 27 2010",
},
"UPDATE":{
"NAME":"vdb-copy",
"VERS":"2.3.5",
"TOOLDATE":"Mar 19 2014",
"RUNDATE":"Sun May 25 2014 6:31:32 AM",
},
};
% json_verify

parse error: invalid object key (must be a string)
                                        { "acc":"SRR060042", "path":"h
                     (right here) ------^
JSON is invalid
linsalrob commented 4 years ago

json_verify doesn't give very meaningful output, it is not because { should be a string.

There are multiple problems with the JSON that prevent it from validating:

  1. commas ending lines that precede }
    • after "VERS":"1.0.0" in FORMATTER
    • after "TOOLDATE":"May 27 2010" in LOADER
    • after "RUNDATE":"Sun May 25 2014 6:31:32 AM" in UPDATE
    • after the penultimate }
  2. The entry should not end with a ;

This should validate:

{
"acc":"SRR060042",
"path":"https://sra-download.ncbi.nlm.nih.gov/traces/sra6/SRR/000058/SRR060042",
"size":7253676923,
"type":"Table",
"platf":"SRA_PLATFORM_ILLUMINA",
"SEQ":58925865,
"SCHEMA":"NCBI:SRA:Illumina:tbl:phred:v2#1.0.4",
"FORMATTER":{
"NAME":"internal",
"VERS":"1.0.0"
},
"LOADER":{
"NAME":"fastq-load",
"VERS":"1.0.20",
"TOOLDATE":"May 27 2010"
},
"UPDATE":{
"NAME":"vdb-copy",
"VERS":"2.3.5",
"TOOLDATE":"Mar 19 2014",
"RUNDATE":"Sun May 25 2014 6:31:32 AM"
}
}
tseemann commented 4 years ago

Thanks @linsalrob - I'm yet to be able to validate JSON (or ASN1) by eye yet. Looks a lot like perl Data::Dumper though :)

klymenko commented 2 years ago

It was fixed in 2.11.2 release. Please confirm.