Bug 393467 - JSON parsing does not ignore white space before values (ints, strings, bools)
Summary: JSON parsing does not ignore white space before values (ints, strings, bools)
Status: RESOLVED FIXED
Alias: None
Product: TCF
Classification: Tools
Component: Agent (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 1.1   Edit
Assignee: Project Inbox CLA
QA Contact: Eugene Tarassov CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-02 17:40 EDT by Jerry Kyn CLA
Modified: 2013-06-05 04:40 EDT (History)
0 users

See Also:


Attachments
my changes to the json.c file to ignore white space (28.76 KB, text/plain)
2012-11-02 17:40 EDT, Jerry Kyn CLA
no flags Details
original boardfile (159 bytes, application/octet-stream)
2012-11-02 17:41 EDT, Jerry Kyn CLA
eugene: iplog-
Details
board file formatted by python -mjson.tool (249 bytes, application/octet-stream)
2012-11-02 17:41 EDT, Jerry Kyn CLA
eugene: iplog-
Details
git patch of my changes to json.c (3.65 KB, patch)
2012-11-05 09:37 EST, Jerry Kyn CLA
mober.at+eclipse: iplog-
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jerry Kyn CLA 2012-11-02 17:40:43 EDT
Created attachment 223137 [details]
my changes to the json.c file to ignore white space

Hi,

I found and error in the json.c parsing functions which do not ignore white space before values.

I am using the json parsing routines in tcf-c-core/agent/tcf/framework/json.c to parse OCD board files. The board files I formatted using the python -mjson.tool which I also use to verify the JSON syntax. This is very useful to identify syntax errors and simple to use.

I simply cat the board file through python using this command.

$ cat <board-file> | python -mjson.tool 

It will produce one of the following outputs
1) stderr: an error message stating invalid or unexpected characters
2) stdout: a nicely formatted JSON text

Once I resolved the errors, I simply redirect stdout to a temp file which I then overwirte the original board file.

I'm attaching my changes to the json.c file and two examples of boardfiles (one original and one after formatting)

thanks,

Jerry
Comment 1 Jerry Kyn CLA 2012-11-02 17:41:25 EDT
Created attachment 223138 [details]
original boardfile
Comment 2 Jerry Kyn CLA 2012-11-02 17:41:50 EDT
Created attachment 223139 [details]
board file formatted by python -mjson.tool
Comment 3 Jerry Kyn CLA 2012-11-05 09:37:26 EST
Created attachment 223177 [details]
git patch of my changes to json.c

NOTE: this patch is slightly different from the full source file I originally attached on friday. The only diff is that the patch is using 'isspace()' instead of individual char comparisons in the macro ignore_whitespace().
Comment 4 Eugene Tarassov CLA 2012-11-06 11:36:33 EST
I have committed the patch.
Thanks!
Comment 5 Martin Oberhuber CLA 2013-05-24 12:39:04 EDT
Comment on attachment 223177 [details]
git patch of my changes to json.c

iplog- since author is in git:

http://git.eclipse.org/c/tcf/org.eclipse.tcf.agent.git/commit?id=f2062bef86a3d63d12519325887cfbd8975b0595