acfr / comma

generic c++ libraries
Other
27 stars 16 forks source link

name-value-get: when json file has error, can be very hard to find #48

Closed junderwood closed 10 years ago

junderwood commented 10 years ago

E.g.: cat config.json | name-value-get something returns: name-value-get: (1): unexpected { 0x7fa13dc12688

if there is a missing trailing comma anywhere in the file. Same for name-value-convert. It can be tiresome to track down the offending comma. It happens a lot, because apparently you must have commas for all but the last entry of a block, and most not have a comma for that last entry.

Would be a big time saver if the output read: error in file on line 32

vlaskine commented 10 years ago

that may not be easily fixable (if at all), since the error comes from the depths of boost

junderwood commented 10 years ago

sorry, my bad... the above should read: cat config.json | name-value-get something --from json and that gives the error:

name-value-get: (16): expected ',' or '}' 0x7f0040f94688

...I only just noticed this does have the line number !! What on earth is the hex value...

I revise my enhancement request to say - could this be a neater error, like:

name-value-get stdin(16): expected...

vlaskine commented 10 years ago

done:

echo -e "{\n \"a\" : \"1\" \n \"b\" : \"2\" \n}" { "a" : "1" "b" : "2" }

echo -e "{\n \"a\" : \"1\" \n \"b\" : \"2\" \n}" | name-value-convert --from json --to path-value name-value-convert: parsing error: line(3): expected ',' or '}'