/** @return the string parsed as a list if possible, null otherwise */ private List<Object> maybeReadList(String string) { if ("".equals(string.trim()) || !string.startsWith("[")) return null; try { return SlimDeserializer.deserialize(string); } catch (SyntaxError e) { return null; } }
/** For dramatic effect, run in debug mode */ @Test public void listDeserializationTest() { List<Object> objects = new ArrayList<Object>(); for (int i = 0; i < 10000; i++) { objects.add(new String("This is string " + i)); } final String serializedList = SlimSerializer.serialize(objects); long start = System.currentTimeMillis(); List<Object> result = SlimDeserializer.deserialize(serializedList); System.out.println(System.currentTimeMillis() - start); assertEquals(objects, result); }