viezel / napp.alloy.adapter.restapi

RestAPI Sync Adapter for Titanium Alloy Framework
197 stars 102 forks source link

parentNode can now be a function #8

Closed FokkeZB closed 11 years ago

FokkeZB commented 11 years ago

Allowing for more advanced traversion (e.g. nested properties)

viezel commented 11 years ago

not a bad idea. Can you show me such a function. Just to test this out?

FokkeZB commented 11 years ago

I use it to read a complex Google Calendar JSON feed:

http://www.google.com/calendar/feeds/developer-calendar@google.com/public/full?alt=json&orderby=starttime&max-results=15&singleevents=true&sortorder=ascending&futureevents=true

viezel commented 11 years ago

nice. seems flexible.

you have time, I could be great with an example for the repo..

FokkeZB commented 11 years ago

Here you are:

        parentNode: function (data) {
                var entries = [];

                _.each(data.feed.entry, function (_entry) {
                        var entry = {};

                        entry.id = _entry.id.$t;
                        entry.startTime = _entry.gd$when[0].startTime;
                        entry.endTime = _entry.gd$when[0].endTime;
                        entry.title = _entry.title.$t;
                        entry.content = _entry.content.$t;

                        entries.push(entry);
                });

                return entries;
        }
viezel commented 11 years ago

thanks for the example code. I bet that will help people out :+1: