go-jsonpointer icon indicating copy to clipboard operation
go-jsonpointer copied to clipboard

Get(), Set(), Delete(), DeleteAny() ops on map.

Open prataprc opened this issue 11 years ago • 11 comments
trafficstars

Use jsonpointer to Get, Set, Delete specific fields inside map[string]interface{}.

  • Get(), Set(), Delete(), DeleteAny() are not thread safe.
  • Get(), Set(), Delete() are idempotent operations.

prataprc avatar Jun 11 '14 06:06 prataprc

I like this idea, but it changes the API of Get and decreases the coverage while adding new, uncovered functions. Can you include some tests? I'm at 100% test coverage now. Would be nice to keep. :)

dustin avatar Jun 12 '14 05:06 dustin

Have been making few changes on go-jsonpointer.

  • optimized parsePointer(), 2x faster.
  • refactored bytes_test.go for test-fixtures.
  • added more benchmarks, for bytes.go, based on json samples under testdata/.
  • added gojson_test.go to benchmark gojson package with golang's, encoding/json.
  • Added Set(), Delete(), DeleteAny() APIs along with Incr(), Incrs(), Decr() APIs.
  • refactored Get().
  • refactored other APIs to use getContainer() and mutateField() functions.

Let me know your thoughts.

Thanks,

prataprc avatar Jun 23 '14 08:06 prataprc

100% code coverage.

prataprc avatar Jun 24 '14 17:06 prataprc

ListPointers() is listing invalid pointers for empty arrays. Is this expected behaviour ?

prataprc avatar Jun 24 '14 17:06 prataprc

squashed offending formatting error. d0dbf11 HEAD@{5}: rebase -i (squash): Added test cases for Set(), Delete(), DeleteAny()

prataprc avatar Jun 26 '14 05:06 prataprc

I have tried to address most of the comments. Cheers.

prataprc avatar Jun 27 '14 05:06 prataprc

Possibly, but in an additive way. Can you rework the set and come up with the smallest set of patches that are distinct? e.g., add the code and the tests together without introducing anything broken or test reduction or formatting Should be a simple rebase -i

On Thu Jun 26 2014 at 10:02:09 PM, prataprc [email protected] wrote:

I have tried to address most of the comments. Cheers.

— Reply to this email directly or view it on GitHub https://github.com/dustin/go-jsonpointer/pull/5#issuecomment-47308142.

dustin avatar Jun 27 '14 05:06 dustin

Squashed the main API implementation and its test cases / benchmarks into a single commit. Cheers.

prataprc avatar Jun 27 '14 05:06 prataprc

Did you push the squashed commits? This is what I pulled:

4ca989e Removed t.Fail() calls that come after t.Errorf(). 6ac1350 fixes based on pull-request comments. a3dfb09 100% coverage. 16b8d33 optimized parsePointer(). 5697da6 Benchmark between gojson Vs encoding/json. 75a5ed2 Get(), Set(), Delete(), DeleteAny() ops on map.

I'd like to avoid the dip in coverage and things that need to be fixed on stuff that comes in.

(github's code review thing is entirely too primitive)

dustin avatar Jun 28 '14 19:06 dustin

Yes that is the list of log messages I have as well. And the hash values match.

If you want I can squash all the commits into a single commit. That way we can avoid a dip in coverage.

prataprc avatar Jun 30 '14 14:06 prataprc

I don't think it needs to be one. Each commit needs to make sense on its own, though. I think your mutation operations with their tests can be in one commit. The benchmarking can be a commit and the optimization can be a commit. I just like them to be clean and not push through cleanups shortly after.

dustin avatar Jun 30 '14 17:06 dustin