qri-io / jsonpointer

golang implementation of IETF RFC6901: https://tools.ietf.org/html/rfc6901
MIT License
16 stars 3 forks source link

Provide a setter #7

Closed nervo closed 4 years ago

nervo commented 4 years ago

What about providing a setter method on pointer ? Today, only a getter (Eval) is available :)

Arqu commented 4 years ago

I think you shouldn't directly modify the Pointer when using it. The way I recommend navigating is by traversing the JSON and building the pointer using Descendant.

Otherwise you can always manually recompile the pointer by manipulating the string representation and just .Parse into a new pointer.

Lastly, the Pointer is just a type alias for []string, so you should be able to cast, manipulate and cast back.

Hope this helps. I will close the issue for now, but can reopen if you feel it needs further exploration.

nervo commented 4 years ago

Thanks for clarifications :)