about points 1, 2 and 3 I really understand what you mean and for this reason I decided to put the project in my github so I could use as sandbox not as final solution, then I can implement globally without worrying much in code conventions and so on, try things that I can share with all of you and then with something "running" we can take decisions on how API should be. Maybe I am too visual guy (I mean I can think better if I have something real to iterate). For this reason I said on my previous comment that I was totally aware that I was not following exactly the API defined in root (for example some return type or throwing IllegalArgumentException), but I think that in this way it is easier to purpose changes to the API, but in any case my intention was to change anything of the official API without consensus. I wanted to show only how using current API can be implemented the operations and see if it fits well or we can find another way that fits better (for example returning JSonValue instead of JsonStructure so we can reuse internal methods), of course if the change was an strong change then I would have updated to latest sources for sure. Note that because of this PoC of JSonPointer now we have some questions that we need to fix and that was exactly my main intention in this case. For example there are some add operations that are not implemented yet because they are pretty simple when you have the most generic one.
But also I understand that I need to change something on how I work because probably with an small more effort I can make PoC and having always the updated API.
Saying that let's see next discussion:
Yes this is exactly how I am doing by applying the operation and then replacing (which is a copy operation of previous nodes) you can see the call here https://github.com/lordofthejars/jsr374-unofficial/blob/master/api/src/main/java/javax/json/JsonPointer.java#L95. I think that using Lambdas we can make the algorithm even more generic but for now I think it is ok.
As you suggested the implementation may reacall on an if to know if it is a JsonArray or JsonObject and depending on that do one change or another.
Maybe we could create an interface that has the add and remove operations (replace can be done by removing and adding), so I can remove the next ifs
if (currentNode.getValueType() == ValueType.OBJECT)
if (currentNode.getValueType() == ValueType.ARRAY)
The only problem I see in this approach is that the interface must be common so for example it could looks like:
JsonStructure add(String name, JsonValue value);
void remove(String name);
The problem that I see is that meanwhile in case of objects the name is really the name of the property you want to add or remove, in case of arrays we must ensure to clarify to the implementators that this string is going to be a position that will need to be translated. I would try to avoid using two different interfaces one for objects and another for arrays because then we will still have the same problem of having to "cast" the instances.