1

I'm looking for tool to work with JSON Schema in java.

Main requirement is interface generation. I'd like to get interfaces from parser API and provide my own implementations to serializer API. The main purpose is to avoid beans pollution with annotations like JsonProperty, JsonIgnore and so on.

There are many tools that can generate java beans (classes) from JSON Schema. Jackson has a feature @JsonSerialize(as=MyInterface.class), but I could not find any tools to generate interfaces from schema.

1
  • any updates on this. Were you able to generate interfaces using javaInterfaces? Commented Dec 13, 2016 at 11:36

2 Answers 2

2

I've never used it, but does http://www.jsonschema2pojo.org/ help? It seems you can even use it from within Java.

Sign up to request clarification or add additional context in comments.

3 Comments

I'm failed to compose a sample with local dereference. The validator I'm using (json-schema-validator) supports local references like "$ref":"#/definitions/bar". jsonschema2pojo fails with error "URI is not absolute".
Ah, OK. That's clearly a failing - maybe raise a bug on the jsonschema2pojo project?
I've tested the java api -- it works well. Unfortunately it supports only schema draft-03. The latest schema version differs (allOf, oneOf instead of extends keyword). Validation is more significant for me than code generation. So I'll use draft-04 with json-schema-validator.
0

Let me show you how to dev the tool.you can do so:

  1. user javascript function Json.parse(),make string like-json trans to js object
  2. then use this object to genrate the javabean format.
  3. something,you shoud care.(1)value type mapping,forexample,how to figure out the string,is date type.(2)loweser_case to camelCase

I dev a tool solve the problem.it is well design and quick more. get the code from my github.

enjoy it from here,I have deploy it on webserver.

I try the top 2 answer's suggestion.one web is can not open.one is slower than my tool.hope you will enjoy my tool.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.