skyscreamer / yoga

Yoga is RESTful but flexible.
http://yoga.skyscreamer.org/
Apache License 2.0
156 stars 66 forks source link

Handle maps in the result traverser #238

Closed johnhearn closed 10 years ago

johnhearn commented 10 years ago

The result traverser treats maps as pojos and therefore does not expose the keys in the map to selectors. With this change, maps are treated specifically and selectors can be applied to their fields. This is working in our application. Any feedback welcomed.

kentongray commented 10 years ago

Just so I can understand the behavior does this mean that maps by default show all keys unless a selector is applied?

sduskis commented 10 years ago

It looks like Maps should only show keys that are are passed in from the url. @johnhearn: can you please confirm that was the intent?

We should also probably think about a way to do a manual configuration for standard fields to show in lieu of @Core. I haven't thought about how that kind of configuration should look.

kentongray commented 10 years ago

yeah, I believe the current version of yoga seems to already have this behavior because I've run into it so I'm trying to figure out if this fixes our issue, we have some maps where the end user can't know the keys in it so i'd really like something like @IncludeChildren or selector=fields(*) or something like that

johnhearn commented 10 years ago

The intent was to mimic the current default behaviour for pojos, that is, keys must be explicitly selected to appear in the output. As far as I know there is currently no way to include default keys, like we can pojo fields with the @ Core annotation. Perhaps a new annotation is needed, something like @CoreMap(keys={"a","b","c"}), although that looks a bit ugly to me and I have not as yet come across a need for it.