get JSON Path from Java Object -


how jsonpointer path particular field? example

{     "name": "test",     "code": 101,     "details": {         "education": "ug",         "age": 0     } } 

if 1 of field have validation issue, need send error in json pointer notation "field":"/details/age" invalid details.

sample error message

{     "errors": [        {          "name": "validation_error",          "details": [            {              "field":"/details/age",              "value": "",              "issue": "invalid param::age",              "location": "body"            }          ],          "message": "invalid data provided"        }      ]  } 

while validating request object how field path in jsonpointer notation above. send json request mapped below object.

@jsoninclude(jsoninclude.include.non_null) @jsonpropertyorder({ "name", "code", "details" }) public class example {      @jsonproperty("name")     private string name;     @jsonproperty("code")     private integer code;     @jsonproperty("details")     private details details;      @jsonproperty("name")     public string getname() {         return name;     }      @jsonproperty("name")     public void setname(string name) {         this.name = name;     }      @jsonproperty("code")     public integer getcode() {         return code;     }      @jsonproperty("code")     public void setcode(integer code) {         this.code = code;     }      @jsonproperty("details")     public details getdetails() {         return details;     }      @jsonproperty("details")     public void setdetails(details details) {         this.details = details;     }  }   public class details {      @jsonproperty("education")     private string education;     @jsonproperty("age")     private integer age;      @jsonproperty("education")     public string geteducation() {         return education;     }      @jsonproperty("education")     public void seteducation(string education) {         this.education = education;     }      @jsonproperty("age")     public integer getage() {         return age;     }      @jsonproperty("age")     public void setage(integer age) {         this.age = age;     }  } 


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -