Putting the change in a different commit is fine.

That code will originate from cake 1.x - where json_encode couldn't be used. in 2.x however, it can and is a safer/more robust solution.