java - How to validate a specific json structure in Jackson? -


i need way validate specific formatted json can represent class (in case book class) strings using jackson. there way of doing using jsonschema? or have in different way

objectmapper mapper = new objectmapper(); jsonschema jsonschema = mapper.generatejsonschema(book.class);

edit

you need use third party library this.

i.e. https://github.com/fge/json-schema-validator

    objectmapper objectmapper = new objectmapper();     // line generate json schema class     jsonnode schemanode = objectmapper.generatejsonschema(stagedetail.class).getschemanode();      // make json jsonnode     jsonnode jsontovalidate = jsonloader.fromstring(json_to_validate);      // validate against schema     processingreport validate = jsonschemafactory.bydefault().getjsonschema(schemanode).validate(jsontovalidate);     // validate.messages contains error massages     system.out.println("valid? " + validate.issuccess()); 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -