Bean { public static <T> T fromJSON(Class<T> beanClass, String json) { Context<T> context = context(beanClass); try { T instance = context.reader.fromJSON(json); context.validator.validate(instance, false); return instance; } catch (IOException e) { throw new UncheckedIOException(e); } }  static void register(Class<?> beanClass); static T fromJSON(Class<T> beanClass, String json); static String toJSON(T bean);  }
@Test void dateFieldFromJavaScript() { TestBean bean = Bean.fromJSON(TestBean.class, "{\"date\": \"2018-05-10T05:42:09.776Z\", \"dateTime\": \"2018-05-10T05:42:09.776Z\", \"zonedDateTime\": \"2018-05-10T05:42:09.776Z\"}"); assertThat(bean.dateField).isEqualTo("2018-05-10"); assertThat(bean.dateTimeField).isEqualTo("2018-05-10T05:42:09.776"); assertThat(bean.zonedDateTimeField).isEqualTo("2018-05-10T05:42:09.776Z"); }
@Test void defaultValue() { TestBean bean = Bean.fromJSON(TestBean.class, "{}"); assertThat(bean.defaultValueField).isEqualTo("defaultValue"); }