question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add the plain, basic visitor pattern to JsonElement and children

See original GitHub issue

I’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:closed
  • Created 8 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
inder123commented, Jun 21, 2015

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.

0reactions
inder123commented, Jun 24, 2015

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found