Created
December 1, 2013 17:03
-
-
Save rgoulter/7736768 to your computer and use it in GitHub Desktop.
Java, Reading Basic JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Map mapFromJSON(String json) throws ScriptException{ | |
ScriptEngineManager factory = new ScriptEngineManager(); | |
ScriptEngine engine = factory.getEngineByName("JavaScript"); | |
engine.eval("var s = " + json); | |
return ((Map)engine.eval("s;")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also. Not saying I'm proud of this (or that this is a good way to do it).
Just demonstrating how cheaply one can use Java's ScriptEngine to read JSON content (if you know what the JSON should be).