squadracorsepolito / jsondbc

JSON to dbc converter
MIT License
3 stars 1 forks source link

Return meaningful errors on worng syntax #5

Closed simoneruffini closed 1 year ago

simoneruffini commented 1 year ago

If the json is incorrectly typed and run through jsondbc it returns no meaningful error on where the syntax is wrong. I need to pre parse the json with jq to understand where the missing comma is.

simoneruffini commented 1 year ago

Moreover with an incorrect json structure at the definition level (incorrectly written json) the application just ends with return code 146. Need more debug info. Try this json https://termbin.com/ejvl

FerroO2000 commented 1 year ago

It uses the default go/json parser and if you try parse a wrong json file, it returns an error. I've added the validation level for all the fields marked as "required" in the doc (remember: a required INT field which can be of value 0 can be omitted)

83cce40d7183ad39feb8fe2109c506ffe78e96f6

simoneruffini commented 1 year ago

The returned information is a lot better but still the line number where the syntax is incorrect is not displayed. Is this fixable?

FerroO2000 commented 1 year ago

I found a work-around to get the line num of a json syntax and type errors. For the errors regarding the validation of the CAN models it's not possible to reference the line. If the convertion is dbc->json, the line is shown