updated knn wrapper to write json file