{"action":"created","issue":{"url":"https://api.github.com/repos/FasterXML/jackson-dataformat-xml/issues/214","repository_url":"https://api.github.com/repos/FasterXML/jackson-dataformat-xml","labels_url":"https://api.github.com/repos/FasterXML/jackson-dataformat-xml/issues/214/labels{/name}","comments_url":"https://api.github.com/repos/FasterXML/jackson-dataformat-xml/issues/214/comments","events_url":"https://api.github.com/repos/FasterXML/jackson-dataformat-xml/issues/214/events","html_url":"https://github.com/FasterXML/jackson-dataformat-xml/issues/214","id":191441100,"number":214,"title":"Nested JsonTypeId annotation","user":{"login":"veeyenkay","id":17000461,"avatar_url":"https://avatars.githubusercontent.com/u/17000461?v=3","gravatar_id":"","url":"https://api.github.com/users/veeyenkay","html_url":"https://github.com/veeyenkay","followers_url":"https://api.github.com/users/veeyenkay/followers","following_url":"https://api.github.com/users/veeyenkay/following{/other_user}","gists_url":"https://api.github.com/users/veeyenkay/gists{/gist_id}","starred_url":"https://api.github.com/users/veeyenkay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/veeyenkay/subscriptions","organizations_url":"https://api.github.com/users/veeyenkay/orgs","repos_url":"https://api.github.com/users/veeyenkay/repos","events_url":"https://api.github.com/users/veeyenkay/events{/privacy}","received_events_url":"https://api.github.com/users/veeyenkay/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-24T06:15:59Z","updated_at":"2016-11-24T19:03:48Z","closed_at":null,"body":"I have a Zoo class which can contain animal of different types (Dog, ...) and has an animalType annotated with @JsonTypeId. The Dog class in turn can contain leash of different types (RopeLeash, ...) and has leashType annotated with @JsonTypeId. When i serialize the Zoo class using below method then the leashType gets set for animalType as well:\r\n`        String zooJson = objectMapper.writeValueAsString(zoo);\r\n`\r\nOutput is:\r\n{\"animal\":{\"leash\":{\"leashColor\":\"RED\"},\"leashType\":\"**ROPE**\"},\"animalType\":\"**ROPE**\"}\r\n\r\n```\r\npublic class Zoo {\r\n    @JsonTypeId\r\n    private AnimalType animalType;\r\n    private Animal animal; \r\n\r\n    @JsonTypeInfo(\r\n            use = JsonTypeInfo.Id.NAME, \r\n            include = JsonTypeInfo.As.EXTERNAL_PROPERTY, \r\n            property = \"animalType\"\r\n            )\r\n    @JsonSubTypes({ \r\n        @JsonSubTypes.Type(value = Cat.class, name = \"CAT\"),                \r\n        @JsonSubTypes.Type(value = Dog.class, name = \"DOG\")                \r\n        })\r\n    public void setAnimal(Animal animal) {\r\n        this.animal = animal;\r\n    }\r\n   //Other getters and setters\r\n}\r\n\r\npublic class Dog extends Animal {\r\n    @JsonTypeId\r\n    private LeashType leashType;\r\n    private Leash leash;\r\n    @JsonTypeInfo(\r\n            use = JsonTypeInfo.Id.NAME, \r\n            include = JsonTypeInfo.As.EXTERNAL_PROPERTY, \r\n            property = \"leashType\"\r\n            )\r\n    @JsonSubTypes({ \r\n        @JsonSubTypes.Type(value = RopeLeash.class, name = \"ROPE\")                \r\n        })\r\n    public void setLeash(Leash leash) {\r\n        this.leash = leash;\r\n    }\r\n   //Other getters and setters\r\n}\r\n\r\npublic class RopeLeash extends Leash {\r\n    private String leashColor;\r\n    //Getter and setter for leashColor\r\n}\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/FasterXML/jackson-dataformat-xml/issues/comments/262832941","html_url":"https://github.com/FasterXML/jackson-dataformat-xml/issues/214#issuecomment-262832941","issue_url":"https://api.github.com/repos/FasterXML/jackson-dataformat-xml/issues/214","id":262832941,"user":{"login":"cowtowncoder","id":55065,"avatar_url":"https://avatars.githubusercontent.com/u/55065?v=3","gravatar_id":"","url":"https://api.github.com/users/cowtowncoder","html_url":"https://github.com/cowtowncoder","followers_url":"https://api.github.com/users/cowtowncoder/followers","following_url":"https://api.github.com/users/cowtowncoder/following{/other_user}","gists_url":"https://api.github.com/users/cowtowncoder/gists{/gist_id}","starred_url":"https://api.github.com/users/cowtowncoder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cowtowncoder/subscriptions","organizations_url":"https://api.github.com/users/cowtowncoder/orgs","repos_url":"https://api.github.com/users/cowtowncoder/repos","events_url":"https://api.github.com/users/cowtowncoder/events{/privacy}","received_events_url":"https://api.github.com/users/cowtowncoder/received_events","type":"User","site_admin":false},"created_at":"2016-11-24T19:03:48Z","updated_at":"2016-11-24T19:03:48Z","body":"Could this possibly be misplaced, as output is in JSON, not XML? If so, could you refile under `jackson-databind` instead?"}}
{"actor":{"display_login":"cowtowncoder"}}