SlimeUtils { public static byte[] toJsonBytes(Slime slime) throws IOException { return toJsonBytes(slime.get()); }  static void copyObject(Inspector from, Cursor to); static byte[] toJsonBytes(Slime slime); static byte[] toJsonBytes(Inspector inspector); static Slime jsonToSlime(byte[] json); static Slime jsonToSlime(String json); static Slime jsonToSlimeOrThrow(String json); static Slime jsonToSlimeOrThrow(byte[] json); static Optional<String> optionalString(Inspector inspector); static Optional<Long> optionalLong(Inspector inspector); static Iterator<Inspector> entriesIterator(Inspector inspector); static Stream<Inspector> entriesStream(Inspector inspector);  }
@Test public void test_slime_to_json() throws IOException { Slime slime = new Slime(); Cursor root = slime.setObject(); root.setString("foo", "foobie"); root.setObject("bar"); String json = Utf8.toString(SlimeUtils.toJsonBytes(slime)); assertThat(json, is("{\"foo\":\"foobie\",\"bar\":{}}")); }