-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Description
The BackupData project has a redundant JSON parsing step when processing MongoDB documents:
BsonDocument → ToString() → JSON string → Parse into JObject → Extract fields → ToString() → Upload
The JObject is only used to extract two fields (_id and _meta.updated). We can read these directly from the BsonDocument and skip the parsing entirely:
// Before
var jObject = JsonConvert.DeserializeObject(document.ToString()) as JObject;
var blobName = jObject["_id"]?.ToString();
var updated = jObject["_meta"]?["updated"]?.ToString();
var json = jObject.ToString();
// After
var blobName = document["_id"].AsString;
var updated = document["_meta"]["updated"].ToUniversalTime();
var json = document.ToJson();This removes the Newtonsoft.Json dependency from the production build and eliminates a redundant parse/serialize cycle. The output format stays the same (JSON files in blob storage), so there's no breaking change for consumers.
Metadata
Metadata
Assignees
Labels
No labels