Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support in JsonGenerator for using native Type Id output #91

Closed
cowtowncoder opened this issue Jul 28, 2013 · 0 comments
Closed

Add support in JsonGenerator for using native Type Id output #91

cowtowncoder opened this issue Jul 28, 2013 · 0 comments
Milestone

Comments

@cowtowncoder
Copy link
Member

Although JSON format does not have a native way of outputting type ids, some other Jackson-supported formats do: for example, YAML does have format-level support for type ids.

Since ability to use native mechanisms is important, and since it is much harder for generators to try to reverse-engineer intent from calls, it would make more sense to add new methods to support this. Initial idea is to add:

  • boolean canWriteTypeId(): called at point where following value would have type id. Should return 'true' iff generator thinks this should be ok (it may or may not be possible to definitely say for some cases)
  • void writeTypeId(String id): may be called iff canWriteTypeId() returned true, and no other output methods have been called yet -- this may throw usual exceptions; but if no exception is thrown, assumption is that write succeeded and Jackson databind should NOT try other write methods

This mechanism is specifically added initially to support YAML type ids; other methods may be added later (if necessary) should other kinds of ids (numbers) are desired.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant