Use PHP typehinting instead of gettype in Json consturctor