bugGPSD - Bugs: bug #39051, ais.py : json output has bad...


bug #39051: ais.py : json output has bad formating for strings

Submitted by:  Jerome <jjl>
Submitted on:  Thu 23 May 2013 09:39:38 AM UTC  
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Mon 01 Jul 2013 10:49:02 AM UTC, comment #1:

Fixed in git, thanks for the bug report.

Eric S. Raymond <esr>
Project Administrator
Thu 23 May 2013 09:39:38 AM UTC, original submission:


In json output, the string values should be double-quoted.
For example, see json grammar on json.org

So some interpreters cannot analyse the ais.py output.

To reproduce (with a type24 aivdm) :
$> python --version
Python 2.6.6
$> json=$(echo '!AIVDM,1,1,,A,H3P;Nbhd44r0TT0000000000000,0*64'| ./ais.py -j)
$> python -c "import sys,json;json.loads(sys.argv[1])" "$json"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python2.6/json/__init__.py", line 307, in loads
return _default_decoder.decode(s)
File "/usr/lib64/python2.6/json/decoder.py", line 319, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib64/python2.6/json/decoder.py", line 336, in raw_decode
obj, end = self._scanner.iterscan(s, **kw).next()
File "/usr/lib64/python2.6/json/scanner.py", line 55, in iterscan
rval, next_pos = action(m, context)
File "/usr/lib64/python2.6/json/decoder.py", line 185, in JSONObject
raise ValueError(errmsg("Expecting object", s, end))
ValueError: Expecting object: line 1 column 64 (char 64)

The produced json :
{"msgtype":24,"repeat":0,"mmsi":235069099,"partno":0,"shipname":KAAN II}
the shipname KAAN II should be "KAAN II"

Attached is a small patch to correct this problem. Surely this is not the most elegant code, but it shows a possible resolution.


Jerome <jjl>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Attached Files
file #28146:  ais_json_string.patch added by jjl (1KiB - text/x-patch)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by esr (Posted a comment)
  • -email is unavailable- added by jjl (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-11-22 esr Open/ClosedOpen => Closed
    2013-07-01 esr StatusNone => Fixed
    2013-05-23 jjl Attached File- => Added ais_json_string.patch, #28146

    Back to the top

    Powered by Savane 3.3