java - jsonschema2pojo not generating pojo classes from json string -


i following link generate java class json? create pojo classes json string (and not schema). using jsonschema2pojo jar of version 0.4.10 not able generate pojo class. code below,

public class app  {     public static void main( string[] args )     {         jcodemodel codemodel = new jcodemodel();                 try {             url source = new url("file:///c://users//...//accession.json");             new schemamapper().generate(codemodel, "accession", "com.test", source);             file dir = new file("d://test");             if(dir.exists()){                 system.out.println("dir available");                 codemodel.build(dir);             }else{                 system.out.println("dir not available");             }          } catch (malformedurlexception e) {             e.printstacktrace();         } catch (ioexception e) {             e.printstacktrace();         }            } } 

so accession.json has json string need converted pojo. can please me here.

i had similar experience using command-line tool. in case, result of not correctly specifying source type (jsonschema or json; default: jsonschema).

i think problem similar: you're using default (no-args) constructor schemamapper. following steps should solve problem:

  1. subclass org.jsonschema2pojo.defaultgenerationconfig, overriding getsourcetype() return sourcetype.json
  2. use instance of subclass schemamapper(rulefactory rulefactory, schemagenerator schemagenerator) constructor (instead of no-args constructor).

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -