Home Ask Login Register

Developers Planet

Your answer is one click away!

Alisettar Huseynli February 2016

JSON reader was expecting a value but found 'function'

I have a collection that contains BsonJavascript object.

    "Name" : "HourlyMP", 
    "MapFunction" : function(){
        var _id = this.srcip + " - " + this.hour
        var valueData = {
            ip: this.srcip,
            session: 1
        emit(_id, valueData);

As you see the value of "MapFunction" field is BsonJavascript. I can Export and Import this data successfully. But when I Deserialize exported json into BsonDocument i get this error:

JSON reader was expecting a value but found 'function'

By the way i am using official C# 2.2 driver and my deserialize code is below:



cubrr February 2016

According to the documentation, BsonSerializer.Deserialize<TNominalType>(String) deserializes a JSON string.

Functions aren't valid in JSON.

Post Status

Asked in February 2016
Viewed 3,383 times
Voted 4
Answered 1 times


Leave an answer

Quote of the day: live life