<p>Writing a ton of web applications leveraging JSON/AJAX, I find myself returning tons literal javascript objects (JSON).  For example, I may be request all the Cats from GetCats.asp.  It would return:</p>

<pre>
[
  { 'id': 0, 'name': 'Persian' },
  { 'id': 1, 'name': 'Calico' },
  { 'id': 2, 'name': 'Tabby' }
]
</pre>

<p>Now, these are all Cat objects with behaviors.  However, if I define a Cat object, function Cat() { }, I know of no EFFICIENT way to coax these literal objects into the behaviors of a user defined object.  </p>

<p>I can do this by brute force of iterating through them and assigning functions, but it's not going to be pretty.  Is there a nice, one line(or few), way of somehow "casting" this behavior onto these literal objects?</p>

There's no getting around the fact that you will have to iterate through all of your simple objects and change them to a different kind of object.  You cannot avoid the loop.  That being said you could create a constructor that takes a simple object like this and copies those values into the new instance.
Like this:
```
```
function Cat(c) {
  this.id = c.id;
  this.name = c.name;
}
Cat.prototype.meow = function() {alert('meow');}
Cat.prototype.displayName= function() {alert(this.name);}

var cats = [
  { 'id': 0, 'name': 'Persian' },
  { 'id': 1, 'name': 'Calico' },
  { 'id': 2, 'name': 'Tabby' }
];

for (i=0,len=cats.length; i<len; i++) {
  cats[i] = new Cat(cats[i]);
}

cats[0].meow();  // displays "meow"
cats[0].displayName();  // display "Persian"
```
```