seth/ej — pull request #8 by sebastian (2012-11-06 14:27:48+00:00)
Title: Complex get set

Hi :)
This pull request is somewhat beefier than the other ones I have added. Bear with me as I try to explain why I added the given functionality.

I often have the need to traverse JSON structures that contain arrays, but do not always know the position of the element in the array that I am looking for, but do know some of its properties.
Say for example I have an array of users, each with a unique id. The order of the users in the array is arbitrary, so accessing them by index does not make sense.

I add a getter that allows the following access pattern instead:

ej:get({"users", {"id", "UserAId"}, "name"}, Users).

This would return a list of names for each user with id UserAId.

I also added the corresponding setters, and support for delete using these complex "path parameters".
For example:

ej:set({"users", {"id", "UserAId"}, "name"}, Users, <<"sebastian">>).

Would set the name parameter of all users with id UserAId to sebastian.
If no such entry exists, one will be added.

Thanks