Added toJSONObject method for Library