Questions tagged [jsonschema2pojo]

The jsonschema2pojo is a tool that takes a json schema document and generates DTO-style Java classes (in the form of .java source files).

The jsonschema2pojo is a tool that takes a JSON Schema or JSON document and generates DTO-style Java classes (in the form of .java source files).

There are currently six ways to use jsonschema2pojo:

  1. as a maven plugin
  2. via the command line
  3. as an ant task
  4. as a gradle plugin
  5. directly from your code (embedded) using jsonschema2pojo-core
  6. from the website
174 questions
14
votes
3 answers

Jackson deserialisation/TypeReference for dynamically loaded pojo class

I have a requirement to get JSON input Pojo instance and I am using Jackson 2 library and below readValue method could deserialise using typeReferencing : POJO_ClassName p = mapper.readValue(new TypeReference< POJO_ClassName >() {}); But the…
Kimchy
  • 501
  • 8
  • 24
11
votes
5 answers

How to Handle Two Different Response in Retrofit

I followed this to POST Data Using Retrofit2 I Used JSON POJO to Parse my POST and GET files So Here If Data inside the Records Is there I will get This Kind of Response { "status": "200", "response": [{ "cnt_id": "201", "phn_no":…
Don't Be negative
  • 1,215
  • 3
  • 19
  • 46
11
votes
2 answers

Database operations in IntentService results into application halt,become unresponsive and giving ANR

I am using an IntentService in a alarm manager to trigger it after every 15 seconds. I have to continuously send large amount data to server and receiving large amount of data in response in background. I have to follow beneath process : I am…
10
votes
3 answers

JSON to POJO with custom annotations

I'm trying to include Spring Boot annotations in my generated Java code from JSON like these: @Entity public class Person { ... } and @Repository public interface PersonRepository extends CrudRepository { } I'm converting from JSON…
Gaʀʀʏ
  • 4,372
  • 3
  • 39
  • 59
8
votes
2 answers

POJOs generated by jsonschema2pojo have annotation which Android Studio doesn't understand

When I generate POJOs via http://www.jsonschema2pojo.org/ I get something like this: import javax.annotation.Generated; import com.google.gson.annotations.Expose; import…
Marian Paździoch
  • 8,813
  • 10
  • 58
  • 103
8
votes
1 answer

Pojo to json schema v4 and vice versa via maven

I am trying to come up with a set of documents for one of our projects where there is a requirement to convert Java POJOs to JSON Schema 4 and sometimes JSON schema 4 back to POJOs. I couldn't find a maven plug-in that does both of it. I was able to…
g0c00l.g33k
  • 2,458
  • 2
  • 31
  • 41
5
votes
2 answers

Json schema with anyOf fields to POJO

I wonder what's the recommended way to generate POJOs for Json schemas with "anyOf" fields? For example, given the following json schemas: hobby.json { "anyOf": [ { "type": {"$ref": "./exercise.json" } }, { "type": {"$ref":…
Liutong Chen
  • 2,915
  • 5
  • 22
  • 29
5
votes
1 answer

Arrays are not being generated List but List
I have a complex schema for which I am generating POJO's. However, I noticed that complex types are not being generated for items inside type array although they are marked type object. I did a quick test with very simple schema { "$schema":…
Madhur Ahuja
  • 22,211
  • 14
  • 71
  • 124
5
votes
1 answer

jsonschema2pojo: referencing objects of the same type

I need to generate Java classes from a JSON schema file and came across jsonschema2pojo. However, I encountered a "problem" when using the ref keyword. For example, if I use the following schema from…
user2035039
  • 961
  • 3
  • 16
  • 30
4
votes
1 answer

How to Run Java Code from Gradle at Build Time

I'm using jsonschema-generator to generate a JSON schema file based on my POJOs. Currently I'm doing it via a test that is run during the gradle build step. This works fine but it doesn't feel right as really what I'm doing is not testing…
Vlad Schnakovszki
  • 8,434
  • 6
  • 80
  • 114
4
votes
1 answer

jsonschema2pojo generating objects of custom annotators as well

I'm generating pojo using jsonschema2pojo maven plugin. Using custom annotator, I'm including some lombok annotations (which works fine) but it also creates variables for annotations. Is there a way to force jsonschema2pojo to not create object…
I Durrani
  • 81
  • 1
  • 5
4
votes
0 answers

How to debug classloader issues without tools

For basic i know classloaders have a hierarchy and sequence default classloaders run as below :- a) bootstrap class loader : runs first and loads all java classes etc. b) Extclassloader : Extclassloaders loads all ext folder jars and java…
Kimchy
  • 501
  • 8
  • 24
4
votes
2 answers

JSR-303 activation in jsonschema2pojo

There is a place in jsonschema2pojo documentation describing possibility to enable JSR-303 annotations generation. If I understand correctly it can be done via Maven plugin configuration. Could someone show how to accomplish it, which tag in plugin…
Dmitry Adonin
  • 1,064
  • 3
  • 16
  • 36
3
votes
2 answers

jsonschema2pojo maven plugin does not generate Java classes

I'm trying to obtain the Java model for the FHIR R4 specification. To accomplish this task, I downloaded the JSON Schema and I try to use jsonschema2pojo maven plugin to generate the source code. I create a simple Maven project and I put the JSON…
xcesco
  • 4,690
  • 4
  • 34
  • 65
3
votes
2 answers

How to change default OutputSchema.java class name generated by jsonschema2pojo in maven's POM

In online tool http://www.jsonschema2pojo.org/ there is an option to set Class Name, so the generated root class will be named as I want it. I cant find the same option in maven-plugin option and the generated root class has default name:…
1
2 3
11 12