Opened 3 years ago

Closed 3 years ago

#3133 closed defect (fixed)

v.what output is not valid JSON format

Reported by: marisn Owned by: grass-dev@…
Priority: normal Milestone: 7.0.5
Component: Vector Version: svn-trunk
Keywords: v.what Cc:
CPU: Unspecified Platform: Unspecified

Description

It seems that wxGUI vector attribute query tool is parsing text attribute values - "\" character is used as an escape character instead of its literal value. Thus \' will cause "invalid JSON" error, \b will render a backspace, \ \ (double backslash) will render as a single \ symbol.

v.db.select map=rm_me@user1                                                     
cat|title
1|\'foo,
2|ba'\'r
3|ba'
4|ba'\b'r
5|ba\\'r
File "/home/maris/soft/grass_trunk/dist.x86_64-pc-linux-gnu/gui/wxpython/mapdisp/frame.py", line 963, in QueryMap
    distance=qdist, encoding=encoding)
  File "/home/maris/soft/grass_trunk/dist.x86_64-pc-linux-gnu/etc/python/grass/script/vector.py", line 395, in vector_what
    raise ScriptError(_("v.what output is not valid JSON format:\n {ret}").format(ret=ret))
ScriptError: v.what output is not valid JSON format:
 {"Coordinates": {"East": "18.484321", "North": "9.264808"},
"Maps":
[{"Map": "rm_me",
"Mapset": "user1",
"Type": "Point",
"Id": 1,
"Categories": [
{"Layer": 1, "Category": 1,
"Driver": "sqlite",
"Database": "/home/maris/grass_data/nc_basic_spm_grass7/user1/sqlite/sqlite.db",
"Table": "rm_me",
"Key_column": "cat",
"Attributes": {"cat": "1",
"title": "\'foo,"}}]}]}

    

Change History (5)

comment:1 Changed 3 years ago by annakrat

In 69178:

v.what: escape backslash in attributes for valid JSON, see #3133

comment:2 Changed 3 years ago by martinl

Milestone: 7.3.07.4.0

Milestone renamed

comment:3 Changed 3 years ago by annakrat

In 69442:

v.what: escape backslash in attributes for valid JSON, see #3133 (merge from trunk, r69178)

comment:4 Changed 3 years ago by annakrat

In 69443:

v.what: escape backslash in attributes for valid JSON, see #3133 (merge from trunk, r69178)

comment:5 Changed 3 years ago by annakrat

Component: wxGUIVector
Milestone: 7.4.07.0.5
Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.