After aggregation I got this result. The _id field is each class's id and I applied {$group:{_id:"$_id", .....
[{ _id: 54c977314f5293b74ea54f96, subject: 'math' }, score: 73.5335 },
{ _id: 54c977314f5293b74ea54f96, subject: 'science' }, score: 56.2192 },
{ _id: 54c977314f5293b74ea54f96, subject: 'history' }, score: 82.8821 },
{ _id: 54c974bdff0d993b4ecf34ce, subject: 'math' }, score: 68.2598 },
{ _id: 54c974bdff0d993b4ecf34ce, subject: 'science' }, score: 77.8712 },
{ _id: 54c974bdff0d993b4ecf34ce, subject: 'history' }, score: 71.9218 },
... ]
The problem is _id value is not string type. so when I send JSON to client, it says malformed JSON.
How can I get string type _id? Thanks in advance.