Bug 13432 – std.json.parseJSON does not report correct line number in Exception

Status
RESOLVED
Resolution
DUPLICATE
Severity
minor
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-09-06T14:48:00Z
Last change time
2016-01-08T18:54:16Z
Assigned to
nobody
Creator
ryan

Attachments

IDFilenameSummaryContent-TypeSize
1419test.jsonsimple json file with syntax errorapplication/json52
1420json_test.dcode to parse json and throw exceptiontext/x-dsrc97

Comments

Comment #0 by ryan — 2014-09-06T14:48:34Z
Created attachment 1419 simple json file with syntax error When std.json.parseJSON is called on a string containing invalid JSON, the returned exception always reports a syntax error on line number 1. The column number seems to give the total number of characters parsed up to the point of the error rather than the number of preceding characters on that line. For example, calling parseJSON on the following: { "key" : { "val1" : 1, "val2" : 2 }, <------ syntax error on line 5, column 4 } throws an exception that reports 'Found '}' when expecting '"'. (Line 1:29)' To parse, I am using "test.json".readText.parseJSON
Comment #1 by ryan — 2014-09-06T14:49:45Z
Created attachment 1420 code to parse json and throw exception
Comment #2 by pastuhov85 — 2015-05-17T08:56:50Z
It seems thant all json is minified before being processed, so example above seen as {"key":{"val1":1,"val2":2},} by Phobos, and the error is on line 1, colimn 29 from this point of view.
Comment #3 by mvalleton.dlang — 2016-01-08T18:54:16Z
*** This issue has been marked as a duplicate of issue 14065 ***