Hi @marc ,
thank you for hint regarding the Json to POJO mapping. I will test it soon.
Until then i verify incoming Json by using a validator this way:
import org.everit.json.schema.Schema;
import org.everit.json.schema.ValidationException;
import org.everit.json.schema.loader.SchemaLoader;
import org.json.JSONObject;
import org.json.JSONTokener;
...
private Schema schema = SchemaLoader
.load(new JSONObject(new JSONTokener(Application.class.getResourceAsStream("/schema/Item.json"))));
...
@Bean
public Consumer<String> itemCreated() {
return s -> {
try {
schema.validate(new JSONObject(new JSONTokener(s)));
} catch (ValidationException e) {
logger.error("item invalid: " + e.toString());
}
logger.info("item created: " + s);
};
}
I have included this dependency in my gradle build:
implementation 'org.everit.json:org.everit.json.schema:1.3.0'
BR Gerhard