i can not map json in java object. issue can not map values v0.1.0 java object can 1 me how can map json java object.i not declare varaible name v0.1.0 use json property annotation . not work me.
how make java object json :
{ "availablevariants": { "v0.1.0": { "resourcename": "raja", "get": "www.google.com", "deltaget": "", "post": null, "put": null, "delete": null }, "v1.1.0": { "resourcename": "raja", "get": "www.google.com", "deltaget": "", "post": null, "put": null, "delete": null } } } not able make java object json .
does problem simpler if think of "v0.1.0" , "v1.1.0" keys in map instead of properties of object? try this:
public class resource { private string resourcename; private string get; private string deltaget; private string post; private string put; private string delete; // public getters , setters } public class variantinfo { // resources indexed version private map<string, resource> availablevariants; // public getter , setter } public variantinfo parsevariants(string json) { objectmapper objectmapper = (wherever jackson object mapper comes from); return objectmapper.readvalue(json, variantinfo.class); }