Bug 124268 - Web Inspector: Build script can't handle line or block comments in Inspector.json.
Summary: Web Inspector: Build script can't handle line or block comments in Inspector....
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P3 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2013-11-13 00:04 PST by James Craig
Modified: 2017-01-13 17:25 PST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Craig 2013-11-13 00:04:41 PST
Build script can't handle line or block comments in Inspector.json.

    /bin/sh -c \"./WebKitBuild/WebCore.build/Debug/Derived\ Sources.build/Script-DD041FBD09D9DDBE0010AF2A.sh\"
python WebCore/inspector/CodeGeneratorInspector.py WebCore/inspector/Inspector.json --output_h_dir . --output_cpp_dir . --output_js_dir .
Traceback (most recent call last):
  File "WebCore/inspector/CodeGeneratorInspector.py", line 1700, in <module>
    json_api = json.loads(json_string)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 383, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded
make: *** [InspectorFrontend.h] Error 1
Command /bin/sh failed with exit code 2
Comment 1 Radar WebKit Bug Importer 2013-11-13 00:04:59 PST
<rdar://problem/15456678>
Comment 2 Joseph Pecoraro 2013-11-13 13:06:51 PST
I don't think comments are actually allowed in JSON.
Comment 3 Joseph Pecoraro 2013-11-13 13:09:35 PST
I assume this is because you had added some comments to Inspector.json?

JSON is solely about data, and comments aren't allowed:
<http://www.ietf.org/rfc/rfc4627.txt>

The error you're seeing actually comes from the Python json library failing to parse the input file. Python's json parser probably adheres to the JSON spec and comments would be invalid.
Comment 4 Joseph Pecoraro 2013-11-13 13:10:43 PST
However, after all of that. We could strip comments before parsing, or just add a "comment" key/value pair. Already almost everything has a "description" property for adding comments / documentation.
Comment 5 BJ Burg 2014-01-25 15:29:06 PST
The code generator could easily read in the file and drop lines starting with #, //, or /* before handing off to the JSON parser. This would be useful in the replay code generator too, so I'll tackle it.
Comment 6 James Craig 2014-02-14 10:03:37 PST
Changing from P2 to P3. It would have been nice when I was learning how the Inspector interface worked, but it wasn’t for explanatory comments. It was so I could comment code blocks to achieve partial builds without deleting my whole JSON object definition. Now that I know how things are generated, this is less important for me, but it might help others who are learning how to contribute to the Web Inspector or any other use of JSON-in-files in WebKit.
Comment 7 BJ Burg 2017-01-13 17:25:03 PST
I don't think it's worth making our JSON not proper JSON just to make it easy to comment out sections of it. You can easily just delete and selectively revert with git/svn.

If you really just want to selectively disable certain commands/events/domains locally without deleting them, it would be trivial to add a fake Platform to the generator then set the 'platform' property to it. This would cause it to not match the generator's platform (mac or ios) and boilerplate for the command wouldn't be generated.

If that is sufficient, I can retitle this and fix it quite quickly. If this is really about comment syntax, I think we should close this bug as NTBF.