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

Have an option to marshal boolean to numeric representation #218

Open
hmaracic opened this issue Apr 23, 2019 · 5 comments
Open

Have an option to marshal boolean to numeric representation #218

hmaracic opened this issue Apr 23, 2019 · 5 comments

Comments

@hmaracic
Copy link

The unmarshaller already understands "0" as false and "1" as true, which is correct per XML specification.

Could it be possible (if it doesn't exist already) to add some configuration option to output "0" and "1" when marshalling JSON, instead of "false" and "true"?

@highsource
Copy link
Owner

You can implement and register a custom booleanish type for this. Let me know if you would like to give it a try, I'll try to provide pointers.

@hmaracic
Copy link
Author

That would be great, thanks!

@highsource
Copy link
Owner

Ok. Start by writing your own boolean type.

See:

https://github.com/highsource/jsonix/blob/master/scripts/src/main/javascript/org/hisrc/jsonix/Jsonix/Schema/XSD/Boolean.js

You can subclass Jsonix.Schema.XSD.Boolean or write one from the scratch, that's fairly simple.

@highsource
Copy link
Owner

The you can use your type in your mappings. An example is here:

#157

@highsource
Copy link
Owner

I even think you can override the default Boolean type like this.

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

2 participants