### Question:
ValueSplitter { public static String[] split(String input) { if (input.startsWith("{") && input.endsWith("}")) { List<String> result = new ArrayList<>(); int openBracket = 0; Integer lastStartIdx = null; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (c == '{') { openBracket++; if (lastStartIdx == null) { lastStartIdx = i; } } if (c == '}') { openBracket--; if (openBracket == 0 && lastStartIdx != null) { String substring = input.substring(lastStartIdx, i + 1); result.add(substring); lastStartIdx = null; } } } return result.toArray(new String[result.size()]); } return Strings.split(input, ','); } private  ValueSplitter(); static String[] split(String input);  }### Answer:
@Test public void testSplitWithSingleValue() throws Exception { String[] strings = ValueSplitter.split("A"); assertEquals(1, strings.length); assertEquals("A", strings[0]); }
@Test public void testSplitWithRegularCSV() throws Exception { String[] strings = ValueSplitter.split("A,B,C"); assertEquals(3, strings.length); }
@Test public void testSplitWithSingleJsonId() throws Exception { String jsonId = "{\"someKey\":\"someValue\"}"; String[] strings = ValueSplitter.split(jsonId); assertEquals(1, strings.length); assertEquals(jsonId, strings[0]); }
@Test public void testSplitWithSingleJsonIdThatHasNestedObjects() throws Exception { String jsonId = "{\"email\":{\"emailAddress\":\"test@test.com\"},\"isContact\":true}"; String[] strings = ValueSplitter.split(jsonId); assertEquals(1, strings.length); assertEquals(jsonId, strings[0]); }
@Test public void testSplitWithMultipleJsonIds() throws Exception { String jsonId = "{\"someKey\":\"someValue\"},{\"someKey\":\"otherValue\"}"; String[] strings = ValueSplitter.split(jsonId); assertEquals(2, strings.length); }
@Test public void testSplitWithMultipleJsonIdsAndNestedJsonObjects() throws Exception { String[] strings = ValueSplitter.split("{\"email\":{\"emailAddress\":\"nouser@test.com\"},\"isContact\":true},{\"email\":{\"emailAddress\":\"otheruser@test.com\"},\"isContact\":contact}"); assertEquals(2, strings.length); }