@Test public void shouldPreserveUnknownKeysInDeserialisation() throws Exception { String jobSpec = IOUtils.toString(getClass().getResourceAsStream("job.json"), UTF_8); final Job job = NomadJson.readJobSpec(jobSpec); assertThat(job.getId(), is("Job-ID")); assertThat(job.getUnmappedProperties().get("Unknown Job String"), is((Object) "Hi")); final HashMap<String, String> expectedJobObject = new HashMap<>(); expectedJobObject.put("Foo", "Bar"); assertThat(job.getUnmappedProperties().get("Unknown Job Object"), is((Object) expectedJobObject)); final UpdateStrategy update = job.getUpdate(); assertThat(update.getUnmappedProperties().get("Unknown Update String"), is((Object) "here too")); final HashMap<String, String> expectedUpdateObject = new HashMap<>(); expectedUpdateObject.put("anything", "goes"); assertThat(update.getUnmappedProperties().get("Unknown Update Object"), is((Object) expectedUpdateObject)); }
public static Job readJobSpec(String jobSpec) throws IOException { return OBJECT_MAPPER.readValue(jobSpec, JobSpec.class).job; }
NomadJson { public static Job readJobSpec(String jobSpec) throws IOException { return OBJECT_MAPPER.readValue(jobSpec, JobSpec.class).job; } }
NomadJson { public static Job readJobSpec(String jobSpec) throws IOException { return OBJECT_MAPPER.readValue(jobSpec, JobSpec.class).job; }  }
NomadJson { public static Job readJobSpec(String jobSpec) throws IOException { return OBJECT_MAPPER.readValue(jobSpec, JobSpec.class).job; }  static Job readJobSpec(String jobSpec); static String asJobSpec(Job job); static String serialize(Object value); static T deserialize(String json, Class<T> clazz); static List<T> deserializeList(String json, Class<T> clazz); }
NomadJson { public static Job readJobSpec(String jobSpec) throws IOException { return OBJECT_MAPPER.readValue(jobSpec, JobSpec.class).job; }  static Job readJobSpec(String jobSpec); static String asJobSpec(Job job); static String serialize(Object value); static T deserialize(String json, Class<T> clazz); static List<T> deserializeList(String json, Class<T> clazz);  }