bignerdranch / Freddy

A reusable framework for parsing JSON in Swift.
MIT License
1.09k stars 120 forks source link

need to expose accessor that takes path as an array instead of variadic parameter #245

Closed mlilback closed 6 years ago

mlilback commented 7 years ago

It is not possible to pass a variadic parameter to another function that takes a variadic function in swift. That makes it impossible to wrap any getXXX methods since they all take variadic parameters.

The best solution I see is to add a version of decode(at:alongPath:type) that takes [JSONPathType] instead of JSONPathType...

I'd make a pull request, but I'm not sure what to do about testing this. There are 7 tests calling the variadic version of decode. Should I duplicate all 7? Or are no tests necessary since the only difference is skipping the syntactic sugar of variadic parameters?

mdmathias commented 7 years ago

Our tests aim for the most complete code coverage that is possible. That said, I'm not sure if you have to duplicate all of the tests you mention. It depends upon what the test is exercising. Feel free to do what you think is right, and we will be happy to discuss with you on your PR.

Out of curiosity, do you have some pseudo code that you can share here that shows what you're after at a high level?

Thanks!

zwaldowski commented 6 years ago

Freddy is in maintenance mode and looking only to make bug fixes right now. We understand that this may be useful in certain scenarios, and welcome a pull request if you're interested. Thanks for your suggestion.

EDIT: We also think of this as a place where Swift can get better. See "Variadic Parameters that Accept Array Inputs".