Added json serializer and updated toJson