Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Actually a non-trivial problem. I would personally suggest the Comment-Stripper library which IMO does a pretty good job of this. Found here: <a href="https://github.com/Slater-Victoroff/CommentStripper?source=cc" rel="nofollow">https://github.com/Slater-Victoroff/CommentStripper?source=cc</a></p> <p>More fully functioned and debugged version was forked a while ago, but hopefully that should solve this issue.</p> <p>Full-disclosure: I wrote this library after asking a similar question and realizing there weren't any great solutions I could find.</p> <p>Alternately if you just want to remove comments I believe you can do it trivially in Python, which you can just call with Jython.</p> <pre><code>import json return json.dumps(json.loads("file.json")) </code></pre> <p>If you're dead set on Native Java you can do basically the same thing using GSON instead. (<a href="http://code.google.com/p/google-gson/" rel="nofollow">http://code.google.com/p/google-gson/</a>) and I assume it's also possible with Jackson (<a href="http://jackson.codehaus.org/" rel="nofollow">http://jackson.codehaus.org/</a>) though I would suggest the lighter GSON for something this simple.</p> <p>GSON example:</p> <pre><code>Gson gson = new Gson(); BufferedReader br = //BufferedReader for your source; String clean = gson.toJson(gson.fromJson(br, Class.class)) </code></pre> <p>Example is given with the understanding that there is some supporting code that needs to go with it, this example only encapsulates the use of GSON. The rest should be pretty trivial (Make a generic type class), check out the GSON docs if you're really having trouble.</p> <p><a href="https://sites.google.com/site/gson/gson-user-guide" rel="nofollow">https://sites.google.com/site/gson/gson-user-guide</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload