SlimeUtils { public static Slime jsonToSlime(byte[] json) { Slime slime = new Slime(); new JsonDecoder().decode(slime, json); return slime; }  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_json_to_slime() { byte[] json = Utf8.toBytes("{\"foo\":\"foobie\",\"bar\":{}}"); Slime slime = SlimeUtils.jsonToSlime(json); assertThat(slime.get().field("foo").asString(), is("foobie")); assertTrue(slime.get().field("bar").valid()); }