gpsd-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gpsd-dev] Tests: About adding a JSON validator


From: Christian Gagneraud
Subject: Re: [gpsd-dev] Tests: About adding a JSON validator
Date: Wed, 06 Jun 2012 17:41:46 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120421 Thunderbird/12.0

On 05/06/12 22:46, Bernd Zeimetz wrote:
Hi,


While working on having the AIS code better tested, I wrote a simple python
script that try to parse the JSON dump of the AIVDM mesages, and I discovered
two syntax errors in it (2 non quoted string values).

what did you use to check for syntax errors? Having something like jsonlint from
python-demjson to validate generated json automatically would be a good thing to
have in the regression tests.

No, I didn't use jsonlint, i wrote a simple python script that loads json from stdin, it will print errors if it can't be loaded. The json.loads() check for validity if I'm not wrong. And it worked quite well to detect comma, colon and quotes issues at least.

Maybe jsonlint is a better solution, the python json decoder is not very sctrict, for example it allows by default NaN, Infinity and -Infinity, which are not part of JSON.

Chris



I then did the same with all the JSON files in test/ but i didn't discover more
problems.

Do you thinks, it would be good to have this kind of thing added to "scons 
check"?

Definitely.

Cheers,

Bernd




--
Christian Gagneraud,
Embedded systems engineer.
Techworks Marine
1 Harbour road
Dun Laoghaire
Co. Dublin
Ireland
Tel: + 353 (0) 1 236 5990
Web: http://www.techworks.ie/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]