I know that this in way that was before, 
but why not use json_encode directly?