Since native ‘json_encode’ allows recursion at this matter, I suppose we can leave current code as it is.
Still I need someone else opinion on this.