Parses a json string, returning either a Map , List<?>, String, Double, Boolean, or null. Fails if duplicate names found.
(String raw)
| 46 | * found. |
| 47 | */ |
| 48 | public static Object parse(String raw) throws IOException { |
| 49 | JsonReader jr = new JsonReader(new StringReader(raw)); |
| 50 | try { |
| 51 | return parseRecursive(jr); |
| 52 | } finally { |
| 53 | try { |
| 54 | jr.close(); |
| 55 | } catch (IOException e) { |
| 56 | logger.log(Level.WARNING, "Failed to close", e); |
| 57 | } |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | private static Object parseRecursive(JsonReader jr) throws IOException { |
| 62 | checkState(jr.hasNext(), "unexpected end of JSON"); |