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 "maximum unescaped char" configuration option for JsonFactory via builder #464

Closed
cowtowncoder opened this issue May 23, 2018 · 1 comment
Milestone

Comments

@cowtowncoder
Copy link
Member

cowtowncoder commented May 23, 2018

Currently CharacterEscapes allows for specifying custom escapes in general, as well as optimized checks for ASCII range of characters (as performance optimization).

But one internal optimization is not exposed via this interface: ability to indicate that "any character codes beyond N" (for example, above 7-bit ASCII range) are to be escaped using standard character escapes.
The reason this would be useful addition is that it would be more efficient for relatively common case of, say, escaping additional HTML characters AND non-ASCII or non-Latin1 characters as well.

Addition could be made in 2.10: but instead of adding this to CharacterEscapes, it makes more sense to use new builder-based factory configuration, I think: mostly because it will be easier to keep pathway optimized -- behavior in much of code being that setting of non-null CharacterEscapes will trigger different encoding pathway.

@cowtowncoder cowtowncoder added 2.9 and removed 2.9 labels May 23, 2018
@cowtowncoder cowtowncoder changed the title Add "maximum unescaped char" limit option in CharacterEscapes Add "maximum unescaped char" configuration option for JsonFactory via builder Jan 15, 2019
@cowtowncoder cowtowncoder added this to the 2.10 milestone Jan 15, 2019
@cowtowncoder
Copy link
Member Author

cowtowncoder commented Jan 15, 2019

Ok, so this is doable. The only (?) unfortunate part is that with 2.10, type erasure, configuration is somewhat cumbersome for regular JsonFactory (casts needed). Will not be a problem with 3.0, fortunately.

With 2.10 this looks like:

        final JsonFactory latinF = ((JsonFactoryBuilder)JsonFactory.builder())
                .highestNonEscapedChar(255)
                .build();

to escape characters beyond Latin-1. With 3.0, cast won't be necessary.

@cowtowncoder cowtowncoder modified the milestones: 2.10, 2.10.0 Jan 15, 2019
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