jsonschema2pojo

How to Handle Two Different Response in Retrofit

大憨熊 提交于 2020-02-28 15:56:15
问题 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": "3251151515", "dat_cnt": "Reset Password request Said to Mail" }, { "cnt_id": "209", "phn_no": "555465484684", "dat_cnt": "Hi DEMO User , Congratulations! Your account has been created successfully." }, { "cnt_id": "210", "phn_no": "4774748", "dat_cnt": "Hi XYZ ,

How to Handle Two Different Response in Retrofit

断了今生、忘了曾经 提交于 2020-02-28 15:54:46
问题 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": "3251151515", "dat_cnt": "Reset Password request Said to Mail" }, { "cnt_id": "209", "phn_no": "555465484684", "dat_cnt": "Hi DEMO User , Congratulations! Your account has been created successfully." }, { "cnt_id": "210", "phn_no": "4774748", "dat_cnt": "Hi XYZ ,

JSR-303 activation in jsonschema2pojo

我是研究僧i 提交于 2020-02-24 11:59:11
问题 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 configuration should be used? Thanks to all! 回答1: I think you are looking for the includeJsr303Annotations parameter. See the plugin documentation: includeJsr303Annotations Whether to include JSR-303 annotations (for schema rules like minimum ,

Unable to generate Java classes from JSON Schema using JsonSchema2Pojo-maven-plugin

心不动则不痛 提交于 2020-01-14 03:06:46
问题 I have used the following URL to understand the usage of JsonSchema2Pojo plugin https://github.com/joelittlejohn/jsonschema2pojo/wiki/Getting-Started#the-maven-plugin However, I am unable to generate any class for the address schema. I have followed the same step as mentioned in the source but still no java class has been generated for address schema. I don't understand what can I do now. Please help me with a proper explanation. 回答1: Double check your pom.xml and your project setup. The

Having null response for a list of objects in REST API call with RestTemplate

柔情痞子 提交于 2020-01-06 07:17:30
问题 So I'm working on a REST client that consumes a REST API to get a JSON object using the Spring RestTemplate. So I get an HTTP 200 OK response but the list (equipment) inside the class object is null. But other fields are fetched. When I do the same request using the Postman it works well. What might be the reason for this? The RestTemplate code snippet : RestTemplate restTemplate = new RestTemplate(); HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.add("Content-Type",

Retrofit 2.0 parse dynamic json from same POJO class

倖福魔咒の 提交于 2019-12-25 16:42:13
问题 What I Have I have a server success response { "response_code": 200, "status": "success", "message": "enqiry chat fetched successfully", "meta_data": { "count": "6" }, "data": { "enquiries": [ ] } } When Error , the same API returns { "response_code": 500, "status": "error", "meta_data": { "count": 0 }, "data": [], "message": "Please specify all required parameter to add enquiries" } What happened At error scenario the data is changed from JsonObject to JsonArray My Problem At success

jsonSchema2pojo jackson deserialisation issue

半世苍凉 提交于 2019-12-24 20:12:06
问题 I am trying use jsonSchema2pojo POJO generating library and i am successful in doing so as well. But issue i am facing is deserialisation Exception when i try to generate map by typeReferencing generated rootClass i.e EsRootDoc(in below code). Here , is the code that i am testing: JCodeModel codeModel = new JCodeModel(); String classLocation = System.getProperty("user.dir")+ "/src/main/java"; GenerationConfig config = new DefaultGenerationConfig() { @Override public boolean isGenerateBuilders

Having null response for a list of objects in REST API call with RestTemplate

梦想与她 提交于 2019-12-13 18:54:36
问题 So I'm working on a REST client that consumes a REST API to get a JSON object using the Spring RestTemplate. So I get an HTTP 200 OK response but the list (equipment) inside the class object is null. But other fields are fetched. When I do the same request using the Postman it works well. What might be the reason for this? The RestTemplate code snippet : RestTemplate restTemplate = new RestTemplate(); HttpHeaders requestHeaders = new HttpHeaders(); requestHeaders.add("Content-Type",

Compare an existed class (file) with a JDefinedClass' content

妖精的绣舞 提交于 2019-12-11 16:57:31
问题 I am generating classes based on received JSON structures on the run time (using jsonschema2pojo). 1. Do we have to save a class as File in Java to be able to make use of it? currently, the class is being saved as follows: codeModel.build(new File("src").getAbsoluteFile()); 2. The goal is to check if the generated class (the body of the class or its file content) is the same as an already existed class file (with the same name) to skip saving that class. On the other hand, If the class' data

make json to pojo from an array without index

心已入冬 提交于 2019-12-11 14:54:39
问题 I'm using retrofit and I have a contact class like this : public class MyContact { private String response; private String message; private Map<String, Object> additionalProperties = new HashMap<String, Object>(); public String getResponse() { return response; } public void setResponse(String response) { this.response = response; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public Map<String, Object>