clearlydefined / clearlydefined/operations
Remove unnecessary JSON parsing in BackupJob
- Dominant language
- JavaScript
- Stars
- 4
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
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:
```csharp
// 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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.