JsonUtil { public JSON parseTrimmedText(String text) { if (text == null) { return null; } String trimmedText = text.trim(); if (trimmedText.startsWith(WHILE_1)) { trimmedText = trimmedText.substring(WHILE_1.length()).trim(); } return JSONSerializer.toJSON(trimmedText); }  static boolean isValidJson(String value); static boolean seemsToBeJsonContentType(String contentType); static boolean seemsToBeJson(String content); JSON parseTrimmedText(String text);  }
@Test public void canParseWithSurroundingWhitespace() { new JsonUtil().parseTrimmedText(" \n\n {1:2}\n\n \t "); }
@Test public void canParseWithPrecedingWhile1() { new JsonUtil().parseTrimmedText(" \n while(1); \n\n {1:2}\n\n \t "); }