Let's say I have a big JSON file to parse, and I want to deserialize it into BsonDocument.
Let's say I want to fetch a JSON file from yahoo weather API.
Here is my code:
var weatherAPI_collection = database.GetCollection<BsonDocument>("weather_API");
string json_data = webClient.DownloadString(URL);
using (var json_reader = new JsonReader(json_data))
{
var serializer = new BsonArraySerializer();
BsonArray bsonArray = serializer.Deserialize(BsonDeserializationContext.CreateRoot(json_reader));
foreach (BsonValue value in bsonArray)
{
Console.WriteLine(value.AsBsonDocument);
weatherAPI_collection.InsertOne(value.AsBsonDocument);
}
}
But I got the error like:
'JSON reader was expecting ':' but found '":"'.'
What should I do? What mistake did I make?