<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.shortcuts import render
from django.http import HttpResponse

from bson.json_util import dumps
from pymongo import MongoClient

client = MongoClient('mongodb://localhost:27017')
db = client['ta_sas']
UserClassifyIdCollection = db['UserClassifyId']

# Create your views here.


def studentList(request):
    students = list(UserClassifyIdCollection.find())
    response = HttpResponse(dumps(students, sort_keys=True), content_type="application/json")
    response['Access-Control-Allow-Origin'] = 'http://localhost:3000'
    return response
<commit_msg>Convert ObjectId to String<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.shortcuts import render
from django.http import HttpResponse

from bson.json_util import dumps
from pymongo import MongoClient

client = MongoClient('mongodb://localhost:27017')
db = client['ta_sas']
UserClassifyIdCollection = db['UserClassifyId']

# Create your views here.

def mapObject(obj):
    obj['_id'] = str(obj.get('_id'))
    return obj

def studentList(request):
    students = list(UserClassifyIdCollection.find())
    convertedStudents = list(map(mapObject, students))
    response = HttpResponse(dumps(convertedStudents, sort_keys=True), content_type="application/json")
    response['Access-Control-Allow-Origin'] = 'http://localhost:3000'
    return response

{'fraction_non_alphanumeric': 0.11343075852470424, 'fraction_numerical': 0.013917884481558803, 'mean_word_length': 5.657407407407407, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3483860', 'n_tokens_mistral': 442, 'n_tokens_neox': 419, 'n_words': 102}