Add the plain, basic visitor pattern to JsonElement and children
See original GitHub issueI’m trying to develop several utilities to extend gson, mostly based on JsonElement
, meaning that I don’t parse directly to an object.
I’m referring to the following kind of extensions: an xpath-like mechanism, a css-like selector, batch modifications (avoiding the cost of reflection), etc.
Technically I can do without, as I’ve made a 20+ lines external implementation using only the JsonElement
and its four public children but still, I feel like it’s something that misses as a hierarchical data structure.
Issue Analytics
- State:
- Created 8 years ago
- Comments:7
Top Results From Across the Web
Visitor Design Pattern in Java - Baeldung
It shows that visitor has visited each element of our structure, depending on the Element type, it dispatched the processing to appropriate ...
Read more >When should I use the Visitor Design Pattern? [closed]
The visitor pattern is used to specify behaviour for different types which is however cohesive. And when you need to add a feature...
Read more >The Visitor Pattern Explained and Implemented in Java
I've received over the years a lot of feedback stating that the Visitor pattern is one of the hardest to grasp. In this...
Read more >The Visitor Pattern Explained - manski's blog
The visitor pattern consists of two parts: a method called Visit() which is implemented by the visitor and is called for every element...
Read more >Visitor Design Pattern Example - Java Code Geeks - 2022
The Visitor Design Pattern provides you with a way to add new operations on the objects without changing the classes of the elements, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
When we first wrote Gson, we did add a visitor pattern for it. It was quite unsatisfying though, so we removed it from the final release. Now, I am not sure what is a good design for it: is it a visitor, or an xpath like mechanism. If you have a proposal, please share. Thanks.
You are partly right: I made up my mind a long time ago, and was hoping that someone will come up with a much better rendition of the visitor pattern that I did. So far, it is elusive, though yours is somewhat better than mine.