jsonparser icon indicating copy to clipboard operation
jsonparser copied to clipboard

Unify names and declarations

Open rami-dabain opened this issue 9 years ago • 5 comments

Currently we have :

EachKey
ArrayEach
ObjectEach

ArrayEach and ObjectEach almost do same function, and have same parameters, but the function declarations/def are bit different

Suggest overriding EachKey with KeyEach (or override to EachObject and EachArray whatever sounds more logial) and make the function declaration/parameters as close as possible

Would be greate to have this marked as to-do, so whenever I have time i'll get back to it

rami-dabain avatar Aug 26 '16 15:08 rami-dabain

The difference between ArrayEach and ObjectEach is an artifact of this library's API evolution over time, unfortunately.

EachKey actually does something fundamentally different from the other two (it's basically a multi-key version of Get). It is named too similarly to the others for my taste, though. Maybe we can turn this issue into a list of suggestions for "jsonparser 2.0" to do breaking API changes all at once?

daboyuka avatar Aug 26 '16 21:08 daboyuka

Sounds like a plan, but lets get all functionality on this version first so we know where we're going in 2.0

rami-dabain avatar Aug 29 '16 08:08 rami-dabain

@daboyuka @rami-dabain sorry for the delay. I'm obviously very busy, and if some of you want to prepare list of the changes which you want to see in next version, I'm glad for any help :)

buger avatar Nov 06 '16 15:11 buger

@buger Same goes for me, I'll try to do it during my next vacation.

rami-dabain avatar Nov 10 '16 14:11 rami-dabain

The last argument to the ArrayEach callback is an error which is always guaranteed to be nil since a5d5436d. Maybe the arg should be renamed '_' with a small function documentation change saying the parameter is no longer of use and will be nil. If and when there is a breaking change to the API, this parameter could be dropped and a return value of error could be use to short circuit the iteration.

FrankReh avatar May 22 '19 12:05 FrankReh