-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
da0aa17
commit 693e885
Showing
2 changed files
with
22 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using MongoDB.Bson; | ||
using MongoDB.Bson.IO; | ||
|
||
namespace ResQueue; | ||
|
||
public static class JsonHelper | ||
{ | ||
public static string ConvertBsonToJson(BsonDocument bsonDocument) | ||
{ | ||
// Relaxed converts Int64 to a standard number representation in JSON | ||
// instead of MongoDB-specific types like NumberLong(), ensuring | ||
// compatibility with JSON parsers that expect standard number types. | ||
|
||
// This mode also normalizes other BSON types, like dates and binary data, | ||
// into formats that work seamlessly in typical JSON contexts. | ||
|
||
var jsonSettings = new JsonWriterSettings { OutputMode = JsonOutputMode.RelaxedExtendedJson }; | ||
return bsonDocument.ToJson(jsonSettings); | ||
} | ||
} |