EllisLab/CodeIgniter — pull request #1285 by Kosmin (2012-04-24 04:13:49+00:00)
Title: Update system/libraries/Javascript.php

I think I've found a bug that crashes the json_encode function when trying to encode a multi-level object from the codeigniter ActiveRecord.

To reproduce, use 3 mysql tables for a many-to-many relationship from people to addresses.

#person_model.php
function get_all_people(){
..
foreach($people as $person){
$person->addresses = $this->addresses_model->get_by_person_id($person->id);
}
..
}

json_encode($this->person_model->get_all_people()); //=> this crashes the json_encode function because the object to array conversion is bogus. The fix is very simple.

Let me know what you think...