-
Notifications
You must be signed in to change notification settings - Fork 1
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
Boolean custom format #4
Comments
What I did if anyone else comes across something like this, I just used a proxy property.
|
@timthedevguy Hi! Thanks for feature request. Your workaround with private props with setters and getters is quite good. I actually have a prototype of what your are asking, that adds support of custom transformation of not only booleans, but for any other type too, including Date, Buffers, etc. But introducing them now would cause some inconsistencies with null/undefined/empty values serialization. A little preview of what it will probably look like: class CapitalizedBoolean implements CustomTransformer<boolean> {
serialize(obj: boolean): string {
return obj ? 'True' : 'False';
}
parse(chardata: string | undefined): boolean {
return chardata == 'True' ? true : false;
}
}
@XmlElem()
class TestTransform {
@XmlChildElem({ transformer: new CapitalizedBoolean() })
flag: boolean;
} The work is in progress, i'll let you now here when a beta version comes out. |
You are awesome! Thanks for looking into the feature request. I'll keep an eye out |
This is the exact package I needed for a pet project, very similar in operation to deserializing XML to C# Class so it's amazing, thank you!
I do have question, the coworker I'm writing this for likes to capitalize everything, so every single mention of true/false in the source XML is True/False. Is there anyway I can write a custom transform for this? Other than modifying the XML directly?
The text was updated successfully, but these errors were encountered: