refactor: API overhaul for better performance and better utility#88
Merged
Conversation
…on for node type errors
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.




Once again, as in #86 , there were TODOs I wanted to address before I finish with the validation, and it once again become a huge PR with all kinds of improvements.
API Changes
While the core library is still very much the same the API has evolved quite a bit.
Going into all detail changes is too excessive, so this is a list of high level changes.
While API did change in many places it should not be hard to adjust the code calling as semantics are mostly the same.
@TerminalOpannotation purely to make the contract of terminal tree operations more clearAppenderAPI as a rich character output API thatJsonAppenderandJurlBuilderwork withTextualNumberto further defer parsing of complicated decimal numbers to potentially avoid allocation during parsingNaN,Infinityand-InfinityinJson5automatically wrapping them into a string in JSON (with also automatic parsing that string back to adoublewhen accessed viadoubleValue())Json5API (SPEC added)JsonArrayandJsonObjectfromJsonValuetoJsonMixeditemsJsonNodeandJsonValuenow also areMap.Entrys (which simplified API and avoids entry instance creation during access/iteration)JsonAccessfor "primitive" types now simply maps the corresponding API method in theJsonValueAPI (as that now has a string-number-boolean "duality" baked into it)JsonAppenderavoid creating intermediateStrings even more (most numbers now also append allocation free)Streamableit now allows callers to either do iterator based consumption or stream based consumption without losing internal knowledge for best performanceJsonSelectablequery API supportingJsonSelectorbased lookups (a JsonPath RFC 9535 inspired feature)JsonNodeAPI now allow to control internal index (cache) behaviour when accessing elements and members (which allow features like lookup or validation API to search without causing much memory consumption through node caching)JsonValueAPI andJsonNodeAPI which now both inheritJsonProbeAPI (required to unify some operation names between those two APIs that were common but named differently)JsonPath#segments()any more during node lookup (did allocate)JurlAPITextAPITextBuilderas achar[]based alternative toStringBuilder(to work well withText)Accompanied by lots of new tests.
Support for more Standards
Json5API now allow to use JSON5-ish input (there are nuances detailed inJSON5-star.md)JsonSelectoris conceptually very close to JsonPath RFC 9535 (again, there are nuances to get a more useful tool with less maintenance burden)Performance
While the list of changes mostly reads like improving the utility and convenience of the APIs these changes were all informed by improving performance. Mainly though avoiding allocations as much as possible and giving users access to operations in a way that let them do what they want with easy so the operations more often than not do just what was needed to get to the outcome the caller wanted. Another big part is once again to avoid certain problematic JDK methods and utility classes as they unfortunately are not done with performance in mind.