Unmarshalling to a subclass with JAXB -


i've json this:

objects:[{    id:"p452365",    type:"photo",    link:"http://xxx.zz" }, {    id:"v7833",    type:"video",    link:"http://xxx.yy",    length:"4.12" } ] 

in superclass entity, there're 2 instance variables: id , type. in extended xmladapter class tried cast entity instances subtype ex. photo

public hashmap<string, list<column>> unmarshal(feeds f) throws exception {         for(feed feed : f.getfeeds()){             system.out.println("entity id feed : " + feed.getid());             for(entity e:feed.getobjects()){                 if (e instanceof photo){                     // of course it's not                 }             }         }         return (hashmap<string, list<column>>)fm.map(f.getfeeds());     } 

of course e isn't instanceof photo, took shot there.:) wanna interfere jaxb process sometime , unmarshall according type value in json.i wonder , how.

one of previous answers similar question may here. using @xmldescrimatornode in eclipselink jaxb (moxy). note i'm moxy tech lead.

you xmladapter. adaptedentity have properties entity , it's subclasses.


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -