Title: Appcelerator / Titanium - Is this way of saving models from a JSON response too memory intensive?
Tags: javascript;backbone.js;underscore.js;appcelerator;titanium-alloy
Question: In my app I'm pulling in a JSON structure using ```Ti.Network.createHTTPClient``` and then looping through the objects and saving each one as a new model. Is this an inefficient way of doing it? I'm new Titanium and Alloy so I'm not sure of best practices. Is there a better way of achieving this?

```var xhr = Ti.Network.createHTTPClient({
    onload: function(e) {
        Ti.API.debug(this.responseText);

        var repsonseJSON = JSON.parse(this.responseText); // parse response as JSON object

        // loop through the data and create/save a model for each one
        _.each(repsonseJSON.brands, function (i) {
            var brand = Alloy.createModel('brands', i);
            theBrands.add(brand);
            brand.save();
        });

        _.each(repsonseJSON.videos, function (i) {
            var video = Alloy.createModel('videos', i);
            theVideos.add(video);
            video.save();
        });

        if (callback) callback(); // callback used to open app in init function
    },
    onerror: function(e) {
        Ti.API.debug(e.error);
        console.log('Error while loading data', e.error);
    },
    timeout: 5000
});
xhr.open("GET", this.data_url); // open the request
xhr.send();  // request is actually sent with this statement
```

Comment: this is more of a backbone specific question than a titanium question, however without writing or modifying your sync adapter this is the best solution



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 1, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2014:00:01/31/14', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><backbone.js><underscore.js><appcelerator><titanium-alloy>', 'Title': 'Appcelerator / Titanium - Is this way of saving models from a JSON response too memory intensive?', 'ViewCount': 375, 'id': 21480152, 'user_AboutMe': '', 'user_AccountId': 1313959.0, 'user_DisplayName': 'shrewdbeans', 'user_Reputation': 11361.0, 'user_Views': 511.0, 'user_id': 1261316.0}}