Get relation through json

In an index view there is this function:




    	var datac = <?php echo json_encode($model) ?>;

    	for (var i = 0; i < datac.length; i++) {

        	displayLocation(datac[i]);

        	}



with this it can be possible to retrieve all record data from a model, but I can’t figure out how to get relation too. Simple to get username instead userid.