{"action":"created","issue":{"url":"https://api.github.com/repos/fomkin/pushka/issues/23","repository_url":"https://api.github.com/repos/fomkin/pushka","labels_url":"https://api.github.com/repos/fomkin/pushka/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/fomkin/pushka/issues/23/comments","events_url":"https://api.github.com/repos/fomkin/pushka/issues/23/events","html_url":"https://github.com/fomkin/pushka/issues/23","id":133594949,"number":23,"title":"Support for sealed trait with mixins","user":{"login":"zv3","id":511910,"avatar_url":"https://avatars.githubusercontent.com/u/511910?v=3","gravatar_id":"","url":"https://api.github.com/users/zv3","html_url":"https://github.com/zv3","followers_url":"https://api.github.com/users/zv3/followers","following_url":"https://api.github.com/users/zv3/following{/other_user}","gists_url":"https://api.github.com/users/zv3/gists{/gist_id}","starred_url":"https://api.github.com/users/zv3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zv3/subscriptions","organizations_url":"https://api.github.com/users/zv3/orgs","repos_url":"https://api.github.com/users/zv3/repos","events_url":"https://api.github.com/users/zv3/events{/privacy}","received_events_url":"https://api.github.com/users/zv3/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-14T23:58:17Z","updated_at":"2016-02-15T07:01:32Z","closed_at":null,"body":"I'm trying to serialize a trait that mixes with some other traits and seems to work quite fine if i try to read/write from the child trait, but when I try to `json.read(..)` or `json.write(..)` an instance from the root trait it throws a `pushka.package$PushkaException`\r\n\r\n```\r\n@pushka\r\nsealed trait Foo\r\n\r\nobject Foo\r\n\r\n@pushka\r\nsealed trait Bar extends Foo \r\n\r\nobject Bar {\r\n  case class A(a: String) extends Bar\r\n}\r\n\r\nval test: Bar = A(\"a\")\r\nwrite(test) // works fine\r\n\r\nval test: Foo = A(\"a\")\r\nwrite(test) // throws an exception on runtime\r\n```\r\nTried to implement a custom serializer using pattern matching but i didn't know how to get an `AST` result from an implicit writer.\r\n\r\nGreat work btw, I got into this project looking for a more natural JSON output from a scalajs pickler library."},"comment":{"url":"https://api.github.com/repos/fomkin/pushka/issues/comments/184088073","html_url":"https://github.com/fomkin/pushka/issues/23#issuecomment-184088073","issue_url":"https://api.github.com/repos/fomkin/pushka/issues/23","id":184088073,"user":{"login":"fomkin","id":1021178,"avatar_url":"https://avatars.githubusercontent.com/u/1021178?v=3","gravatar_id":"","url":"https://api.github.com/users/fomkin","html_url":"https://github.com/fomkin","followers_url":"https://api.github.com/users/fomkin/followers","following_url":"https://api.github.com/users/fomkin/following{/other_user}","gists_url":"https://api.github.com/users/fomkin/gists{/gist_id}","starred_url":"https://api.github.com/users/fomkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fomkin/subscriptions","organizations_url":"https://api.github.com/users/fomkin/orgs","repos_url":"https://api.github.com/users/fomkin/repos","events_url":"https://api.github.com/users/fomkin/events{/privacy}","received_events_url":"https://api.github.com/users/fomkin/received_events","type":"User","site_admin":false},"created_at":"2016-02-15T07:01:32Z","updated_at":"2016-02-15T07:01:32Z","body":"> I'm trying to serialize a trait that mixes with some other traits\r\n\r\nFor now writer of `Foo` doesn't know about subclasses of `Bar`.\r\n\r\n> Tried to implement a custom serializer using pattern matching but i didn't know how to get an AST result from an implicit writer.\r\n\r\nUse `pushka.write` and `pushka.read` instead of `pushka.json.*`."}}