How to serialize output from schemacrawler to JSON in Java?

63 views Asked by At

I would like to upgrade schemacrawler that I use from version 11.01.01 to version 16.20.5. I've already managed to adapt most of the code, but there is this one last thing I can't figure out.

The code using schemacrawler 11.01.01 created a JSON output this way:

OutputOptions outputOptions = new OutputOptions(TextOutputFormat.json.getFormat(), file);

Both OutputOptions and TextOutputFormat were in schemacrawler.tools.options package.

How to implement this functionality in the new version? Could you please help me?

I found the information that writing output to JSON should be possible and how to do it using the command line. But I need an example of how to do it in Java. I see that there is Jackson, but I still don't know how to use it with schemacrawler.

1

There are 1 answers

5
Sualeh Fatehi On

Anna,

You need to use the serialize command with SchemaCrawler, as well as set the output format to JSON. There are now builders to build the options. Since you are jumping ahead by a few major versions of SchemaCrawler, I have created a working example for you at https://github.com/sualeh/sc-example Please use this as a starting point for your code.

Sualeh Fatehi
SchemaCrawler