Decode BSON stream to human-readable string
I'm writing a C# tool which retrieves and aggregates some data from an Oracle DB and displays it in a clean and readable format.
I came across this VARCHAR column, which contains a BSON stream. I'd like to decode to something human-readable (JSON should do the job).
I'm trying to use Newtonsoft.Json.Bson to de-serialize this stream. I'm using the following code:
byte rawData = new byte { 226, 6, 0, 0, 3, 68, 101, 102, 97, 117, 108, 116, 82, 101, 118, 101, 114, 115, 101, 82, 101, 113, 117, 101, 115, 116, 52, 73, 84, 84, 73, 0, 193, 6, 0, 0, 3, 111, 114, 100, 101, 114, 80, 97, 114, 97, 109, 115, 0, 175, 6, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 108, 105, 115, 116, 0, 144, 6, 0, 0, 0, 144, 6, 0, 0, 4, 108, 105, 115, 116, 0, 133, 6, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 105, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 78, 0, 0, 0, 0, 78, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 11, 0, 0, 0, 51, 51, 52, 49, 50, 56, 52, 52, 57, 52, 0, 2, 99, 111, 100, 101, 0, 7, 0, 0, 0, 77, 83, 73, 83, 68, 78, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 163, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 136, 0, 0, 0, 0, 136, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 65, 0, 0, 0, 51, 55, 56, 50, 122, 85, 68, 68, 89, 67, 56, 57, 114, 104, 99, 76, 78, 57, 48, 101, 71, 56, 74, 113, 52, 122, 66, 75, 87, 97, 119, 50, 69, 69, 67, 120, 106, 105, 57, 118, 115, 110, 103, 86, 117, 79, 86, 73, 71, 77, 88, 106, 48, 77, 79, 53, 120, 83, 55, 65, 84, 50, 114, 56, 0, 2, 99, 111, 100, 101, 0, 11, 0, 0, 0, 77, 101, 115, 115, 97, 103, 101, 83, 101, 113, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 111, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 84, 0, 0, 0, 0, 84, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 7, 0, 0, 0, 79, 112, 67, 111, 100, 101, 0, 2, 99, 111, 100, 101, 0, 17, 0, 0, 0, 67, 95, 79, 80, 69, 82, 65, 84, 73, 79, 78, 95, 67, 79, 68, 69, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 115, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 88, 0, 0, 0, 0, 88, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 9, 0, 0, 0, 79, 112, 82, 101, 97, 115, 111, 110, 0, 2, 99, 111, 100, 101, 0, 19, 0, 0, 0, 67, 95, 79, 80, 69, 82, 65, 84, 73, 79, 78, 95, 82, 69, 65, 83, 79, 78, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 116, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 89, 0, 0, 0, 0, 89, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 13, 0, 0, 0, 67, 108, 105, 101, 110, 116, 83, 117, 98, 83, 121, 115, 0, 2, 99, 111, 100, 101, 0, 16, 0, 0, 0, 67, 95, 67, 76, 73, 69, 78, 84, 95, 83, 85, 66, 83, 89, 83, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 125, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 98, 0, 0, 0, 0, 98, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 14, 0, 0, 0, 67, 108, 105, 101, 110, 116, 70, 105, 110, 73, 110, 102, 111, 0, 2, 99, 111, 100, 101, 0, 24, 0, 0, 0, 67, 95, 67, 76, 73, 69, 78, 84, 95, 70, 73, 78, 65, 78, 67, 73, 65, 76, 95, 73, 78, 70, 79, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 117, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 90, 0, 0, 0, 0, 90, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 15, 0, 0, 0, 50, 48, 49, 56, 49, 50, 50, 56, 49, 53, 51, 57, 50, 50, 0, 2, 99, 111, 100, 101, 0, 15, 0, 0, 0, 79, 80, 69, 82, 65, 84, 73, 79, 78, 95, 68, 65, 84, 69, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 108, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 81, 0, 0, 0, 0, 81, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 16, 0, 0, 0, 50, 50, 50, 48, 49, 51, 51, 52, 49, 50, 56, 52, 52, 57, 52, 0, 2, 99, 111, 100, 101, 0, 5, 0, 0, 0, 73, 77, 83, 73, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 95, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 68, 0, 0, 0, 0, 68, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 3, 0, 0, 0, 51, 56, 0, 2, 99, 111, 100, 101, 0, 5, 0, 0, 0, 80, 82, 79, 70, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 94, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 67, 0, 0, 0, 0, 67, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 2, 0, 0, 0, 80, 0, 2, 99, 111, 100, 101, 0, 5, 0, 0, 0, 84, 89, 80, 69, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 93, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 66, 0, 0, 0, 0, 66, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 2, 0, 0, 0, 48, 0, 2, 99, 111, 100, 101, 0, 4, 0, 0, 0, 68, 79, 77, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 94, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 67, 0, 0, 0, 0, 67, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 2, 0, 0, 0, 49, 0, 2, 99, 111, 100, 101, 0, 5, 0, 0, 0, 83, 86, 73, 83, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 107, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 80, 0, 0, 0, 0, 80, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 6, 0, 0, 0, 79, 75, 73, 68, 83, 0, 2, 99, 111, 100, 101, 0, 14, 0, 0, 0, 79, 70, 70, 69, 82, 73, 78, 71, 95, 67, 79, 68, 69, 0, 0, 0, 0, 0, 0, 0, 0 };
MemoryStream memoryStream = new MemoryStream(rawData);
using (BsonDataReader bsonDataReader = new BsonDataReader(memoryStream))
{
JsonSerializer jsonSerializer = new JsonSerializer();
String test = jsonSerializer.Deserialize(bsonDataReader).ToString();
}
(byte array brutally initialized for the sake of brevity)
Executing this code produces the following output in the "test" variable:
{
"DefaultReverseRequest4ITTI": {
"orderParams": {
"complexpropertylist": "kAYAAARsaXN0AIUGAAADY29tcGxleHByb3BlcnR5AGkAAAAFY29tcGxleHByb3BlcnR5AE4AAAAATgAAAAJjb21wbGV4dHlwZQARAAAAV09Db21tb25PYmpQYXJhbQACdmFsdWUACwAAADMzNDEyODQ0OTQAAmNvZGUABwAAAE1TSVNETgAAAANjb21wbGV4cHJvcGVydHkAowAAAAVjb21wbGV4cHJvcGVydHkAiAAAAACIAAAAAmNvbXBsZXh0eXBlABEAAABXT0NvbW1vbk9ialBhcmFtAAJ2YWx1ZQBBAAAAMzc4MnpVRERZQzg5cmhjTE45MGVHOEpxNHpCS1dhdzJFRUN4amk5dnNuZ1Z1T1ZJR01YajBNTzV4UzdBVDJyOAACY29kZQALAAAATWVzc2FnZVNlcQAAAANjb21wbGV4cHJvcGVydHkAbwAAAAVjb21wbGV4cHJvcGVydHkAVAAAAABUAAAAAmNvbXBsZXh0eXBlABEAAABXT0NvbW1vbk9ialBhcmFtAAJ2YWx1ZQAHAAAAT3B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b21wbGV4cHJvcGVydHkAXgAAAAVjb21wbGV4cHJvcGVydHkAQwAAAABDAAAAAmNvbXBsZXh0eXBlABEAAABXT0NvbW1vbk9ialBhcmFtAAJ2YWx1ZQACAAAAUAACY29kZQAFAAAAVFlQRQAAAANjb21wbGV4cHJvcGVydHkAXQAAAAVjb21wbGV4cHJvcGVydHkAQgAAAABCAAAAAmNvbXBsZXh0eXBlABEAAABXT0NvbW1vbk9ialBhcmFtAAJ2YWx1ZQACAAAAMAACY29kZQAEAAAARE9NAAAAA2NvbXBsZXhwcm9wZXJ0eQBeAAAABWNvbXBsZXhwcm9wZXJ0eQBDAAAAAEMAAAACY29tcGxleHR5cGUAEQAAAFdPQ29tbW9uT2JqUGFyYW0AAnZhbHVlAAIAAAAxAAJjb2RlAAUAAABTVklTAAAAA2NvbXBsZXhwcm9wZXJ0eQBrAAAABWNvbXBsZXhwcm9wZXJ0eQBQAAAAAFAAAAACY29tcGxleHR5cGUAEQAAAFdPQ29tbW9uT2JqUGFyYW0AAnZhbHVlAAYAAABPS0lEUwACY29kZQAOAAAAT0ZGRVJJTkdfQ09ERQAAAAAA"
}
}
}
From my understanding, this is happening because the "complexpropertylist" field contains a byte array itself (maybe base64-encoded?).
So, how can I tell the de-serializer to recursively process every child node?
Any help is sincerely appreciated.
c# json.net bson
add a comment |
I'm writing a C# tool which retrieves and aggregates some data from an Oracle DB and displays it in a clean and readable format.
I came across this VARCHAR column, which contains a BSON stream. I'd like to decode to something human-readable (JSON should do the job).
I'm trying to use Newtonsoft.Json.Bson to de-serialize this stream. I'm using the following code:
byte rawData = new byte { 226, 6, 0, 0, 3, 68, 101, 102, 97, 117, 108, 116, 82, 101, 118, 101, 114, 115, 101, 82, 101, 113, 117, 101, 115, 116, 52, 73, 84, 84, 73, 0, 193, 6, 0, 0, 3, 111, 114, 100, 101, 114, 80, 97, 114, 97, 109, 115, 0, 175, 6, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 108, 105, 115, 116, 0, 144, 6, 0, 0, 0, 144, 6, 0, 0, 4, 108, 105, 115, 116, 0, 133, 6, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 105, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 78, 0, 0, 0, 0, 78, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 11, 0, 0, 0, 51, 51, 52, 49, 50, 56, 52, 52, 57, 52, 0, 2, 99, 111, 100, 101, 0, 7, 0, 0, 0, 77, 83, 73, 83, 68, 78, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 163, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 136, 0, 0, 0, 0, 136, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 65, 0, 0, 0, 51, 55, 56, 50, 122, 85, 68, 68, 89, 67, 56, 57, 114, 104, 99, 76, 78, 57, 48, 101, 71, 56, 74, 113, 52, 122, 66, 75, 87, 97, 119, 50, 69, 69, 67, 120, 106, 105, 57, 118, 115, 110, 103, 86, 117, 79, 86, 73, 71, 77, 88, 106, 48, 77, 79, 53, 120, 83, 55, 65, 84, 50, 114, 56, 0, 2, 99, 111, 100, 101, 0, 11, 0, 0, 0, 77, 101, 115, 115, 97, 103, 101, 83, 101, 113, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 111, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 84, 0, 0, 0, 0, 84, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 7, 0, 0, 0, 79, 112, 67, 111, 100, 101, 0, 2, 99, 111, 100, 101, 0, 17, 0, 0, 0, 67, 95, 79, 80, 69, 82, 65, 84, 73, 79, 78, 95, 67, 79, 68, 69, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 115, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 88, 0, 0, 0, 0, 88, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 9, 0, 0, 0, 79, 112, 82, 101, 97, 115, 111, 110, 0, 2, 99, 111, 100, 101, 0, 19, 0, 0, 0, 67, 95, 79, 80, 69, 82, 65, 84, 73, 79, 78, 95, 82, 69, 65, 83, 79, 78, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 116, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 89, 0, 0, 0, 0, 89, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 13, 0, 0, 0, 67, 108, 105, 101, 110, 116, 83, 117, 98, 83, 121, 115, 0, 2, 99, 111, 100, 101, 0, 16, 0, 0, 0, 67, 95, 67, 76, 73, 69, 78, 84, 95, 83, 85, 66, 83, 89, 83, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 125, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 98, 0, 0, 0, 0, 98, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 14, 0, 0, 0, 67, 108, 105, 101, 110, 116, 70, 105, 110, 73, 110, 102, 111, 0, 2, 99, 111, 100, 101, 0, 24, 0, 0, 0, 67, 95, 67, 76, 73, 69, 78, 84, 95, 70, 73, 78, 65, 78, 67, 73, 65, 76, 95, 73, 78, 70, 79, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 117, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 90, 0, 0, 0, 0, 90, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 15, 0, 0, 0, 50, 48, 49, 56, 49, 50, 50, 56, 49, 53, 51, 57, 50, 50, 0, 2, 99, 111, 100, 101, 0, 15, 0, 0, 0, 79, 80, 69, 82, 65, 84, 73, 79, 78, 95, 68, 65, 84, 69, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 108, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 81, 0, 0, 0, 0, 81, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 16, 0, 0, 0, 50, 50, 50, 48, 49, 51, 51, 52, 49, 50, 56, 52, 52, 57, 52, 0, 2, 99, 111, 100, 101, 0, 5, 0, 0, 0, 73, 77, 83, 73, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 95, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 68, 0, 0, 0, 0, 68, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 3, 0, 0, 0, 51, 56, 0, 2, 99, 111, 100, 101, 0, 5, 0, 0, 0, 80, 82, 79, 70, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 94, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 67, 0, 0, 0, 0, 67, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 2, 0, 0, 0, 80, 0, 2, 99, 111, 100, 101, 0, 5, 0, 0, 0, 84, 89, 80, 69, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 93, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 66, 0, 0, 0, 0, 66, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 2, 0, 0, 0, 48, 0, 2, 99, 111, 100, 101, 0, 4, 0, 0, 0, 68, 79, 77, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 94, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 67, 0, 0, 0, 0, 67, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 2, 0, 0, 0, 49, 0, 2, 99, 111, 100, 101, 0, 5, 0, 0, 0, 83, 86, 73, 83, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 107, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 80, 0, 0, 0, 0, 80, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 6, 0, 0, 0, 79, 75, 73, 68, 83, 0, 2, 99, 111, 100, 101, 0, 14, 0, 0, 0, 79, 70, 70, 69, 82, 73, 78, 71, 95, 67, 79, 68, 69, 0, 0, 0, 0, 0, 0, 0, 0 };
MemoryStream memoryStream = new MemoryStream(rawData);
using (BsonDataReader bsonDataReader = new BsonDataReader(memoryStream))
{
JsonSerializer jsonSerializer = new JsonSerializer();
String test = jsonSerializer.Deserialize(bsonDataReader).ToString();
}
(byte array brutally initialized for the sake of brevity)
Executing this code produces the following output in the "test" variable:
{
"DefaultReverseRequest4ITTI": {
"orderParams": {
"complexpropertylist": "kAYAAARsaXN0AIUGAAADY29tcGxleHByb3BlcnR5AGkAAAAFY29tcGxleHByb3BlcnR5AE4AAAAATgAAAAJjb21wbGV4dHlwZQARAAAAV09Db21tb25PYmpQYXJhbQACdmFsdWUACwAAADMzNDEyODQ0OTQAAmNvZGUABwAAAE1TSVNETgAAAANjb21wbGV4cHJvcGVydHkAowAAAAVjb21wbGV4cHJvcGVydHkAiAAAAACIAAAAAmNvbXBsZXh0eXBlABEAAABXT0NvbW1vbk9ialBhcmFtAAJ2YWx1ZQBBAAAAMzc4MnpVRERZQzg5cmhjTE45MGVHOEpxNHpCS1dhdzJFRUN4amk5dnNuZ1Z1T1ZJR01YajBNTzV4UzdBVDJyOAACY29kZQALAAAATWVzc2FnZVNlcQAAAANjb21wbGV4cHJvcGVydHkAbwAAAAVjb21wbGV4cHJvcGVydHkAVAAAAABUAAAAAmNvbXBsZXh0eXBlABEAAABXT0NvbW1vbk9ialBhcmFtAAJ2YWx1ZQAHAAAAT3BDb2RlAAJjb2RlABEAAABDX09QRVJBVElPTl9DT0RFAAAAA2NvbXBsZXhwcm9wZXJ0eQBzAAAABWNvbXBsZXhwcm9wZXJ0eQBYAAAAAFgAAAACY29tcGxleHR5cGUAEQAAAFdPQ29tbW9uT2JqUGFyYW0AAnZhbHVlAAkAAABPcFJlYXNvbgACY29kZQATAAAAQ19PUEVSQVRJT05fUkVBU09OAAAAA2NvbXBsZXhwcm9wZXJ0eQB0AAAABWNvbXBsZXhwcm9wZXJ0eQBZAAAAAFkAAAACY29tcGxleHR5cGUAEQAAAFdPQ29tbW9uT2JqUGFyYW0AAnZhbHVlAA0AAABDbGllbnRTdWJTeXMAAmNvZGUAEAAA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PQ29tbW9uT2JqUGFyYW0AAnZhbHVlAAIAAAAxAAJjb2RlAAUAAABTVklTAAAAA2NvbXBsZXhwcm9wZXJ0eQBrAAAABWNvbXBsZXhwcm9wZXJ0eQBQAAAAAFAAAAACY29tcGxleHR5cGUAEQAAAFdPQ29tbW9uT2JqUGFyYW0AAnZhbHVlAAYAAABPS0lEUwACY29kZQAOAAAAT0ZGRVJJTkdfQ09ERQAAAAAA"
}
}
}
From my understanding, this is happening because the "complexpropertylist" field contains a byte array itself (maybe base64-encoded?).
So, how can I tell the de-serializer to recursively process every child node?
Any help is sincerely appreciated.
c# json.net bson
There's no way to do this automagically, AFAIK. I think you're going to have to write a customJsonConverter
that does this.
– Ian Kemp
Dec 28 '18 at 19:54
By any chance, do you know any article or documentation about doing that? I'm totally new to this library
– kleewan
Dec 28 '18 at 20:40
What is the expected output if everything worked the way you wanted it to?
– Brian Rogers
Dec 28 '18 at 22:56
add a comment |
I'm writing a C# tool which retrieves and aggregates some data from an Oracle DB and displays it in a clean and readable format.
I came across this VARCHAR column, which contains a BSON stream. I'd like to decode to something human-readable (JSON should do the job).
I'm trying to use Newtonsoft.Json.Bson to de-serialize this stream. I'm using the following code:
byte rawData = new byte { 226, 6, 0, 0, 3, 68, 101, 102, 97, 117, 108, 116, 82, 101, 118, 101, 114, 115, 101, 82, 101, 113, 117, 101, 115, 116, 52, 73, 84, 84, 73, 0, 193, 6, 0, 0, 3, 111, 114, 100, 101, 114, 80, 97, 114, 97, 109, 115, 0, 175, 6, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 108, 105, 115, 116, 0, 144, 6, 0, 0, 0, 144, 6, 0, 0, 4, 108, 105, 115, 116, 0, 133, 6, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 105, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 78, 0, 0, 0, 0, 78, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 11, 0, 0, 0, 51, 51, 52, 49, 50, 56, 52, 52, 57, 52, 0, 2, 99, 111, 100, 101, 0, 7, 0, 0, 0, 77, 83, 73, 83, 68, 78, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 163, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 136, 0, 0, 0, 0, 136, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 65, 0, 0, 0, 51, 55, 56, 50, 122, 85, 68, 68, 89, 67, 56, 57, 114, 104, 99, 76, 78, 57, 48, 101, 71, 56, 74, 113, 52, 122, 66, 75, 87, 97, 119, 50, 69, 69, 67, 120, 106, 105, 57, 118, 115, 110, 103, 86, 117, 79, 86, 73, 71, 77, 88, 106, 48, 77, 79, 53, 120, 83, 55, 65, 84, 50, 114, 56, 0, 2, 99, 111, 100, 101, 0, 11, 0, 0, 0, 77, 101, 115, 115, 97, 103, 101, 83, 101, 113, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 111, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 84, 0, 0, 0, 0, 84, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 7, 0, 0, 0, 79, 112, 67, 111, 100, 101, 0, 2, 99, 111, 100, 101, 0, 17, 0, 0, 0, 67, 95, 79, 80, 69, 82, 65, 84, 73, 79, 78, 95, 67, 79, 68, 69, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 115, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 88, 0, 0, 0, 0, 88, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 9, 0, 0, 0, 79, 112, 82, 101, 97, 115, 111, 110, 0, 2, 99, 111, 100, 101, 0, 19, 0, 0, 0, 67, 95, 79, 80, 69, 82, 65, 84, 73, 79, 78, 95, 82, 69, 65, 83, 79, 78, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 116, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 89, 0, 0, 0, 0, 89, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 13, 0, 0, 0, 67, 108, 105, 101, 110, 116, 83, 117, 98, 83, 121, 115, 0, 2, 99, 111, 100, 101, 0, 16, 0, 0, 0, 67, 95, 67, 76, 73, 69, 78, 84, 95, 83, 85, 66, 83, 89, 83, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 125, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 98, 0, 0, 0, 0, 98, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 14, 0, 0, 0, 67, 108, 105, 101, 110, 116, 70, 105, 110, 73, 110, 102, 111, 0, 2, 99, 111, 100, 101, 0, 24, 0, 0, 0, 67, 95, 67, 76, 73, 69, 78, 84, 95, 70, 73, 78, 65, 78, 67, 73, 65, 76, 95, 73, 78, 70, 79, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 117, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 90, 0, 0, 0, 0, 90, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 15, 0, 0, 0, 50, 48, 49, 56, 49, 50, 50, 56, 49, 53, 51, 57, 50, 50, 0, 2, 99, 111, 100, 101, 0, 15, 0, 0, 0, 79, 80, 69, 82, 65, 84, 73, 79, 78, 95, 68, 65, 84, 69, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 108, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 81, 0, 0, 0, 0, 81, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 16, 0, 0, 0, 50, 50, 50, 48, 49, 51, 51, 52, 49, 50, 56, 52, 52, 57, 52, 0, 2, 99, 111, 100, 101, 0, 5, 0, 0, 0, 73, 77, 83, 73, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 95, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 68, 0, 0, 0, 0, 68, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 3, 0, 0, 0, 51, 56, 0, 2, 99, 111, 100, 101, 0, 5, 0, 0, 0, 80, 82, 79, 70, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 94, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 67, 0, 0, 0, 0, 67, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 2, 0, 0, 0, 80, 0, 2, 99, 111, 100, 101, 0, 5, 0, 0, 0, 84, 89, 80, 69, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 93, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 66, 0, 0, 0, 0, 66, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 2, 0, 0, 0, 48, 0, 2, 99, 111, 100, 101, 0, 4, 0, 0, 0, 68, 79, 77, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 94, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 67, 0, 0, 0, 0, 67, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 2, 0, 0, 0, 49, 0, 2, 99, 111, 100, 101, 0, 5, 0, 0, 0, 83, 86, 73, 83, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 107, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 80, 0, 0, 0, 0, 80, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 6, 0, 0, 0, 79, 75, 73, 68, 83, 0, 2, 99, 111, 100, 101, 0, 14, 0, 0, 0, 79, 70, 70, 69, 82, 73, 78, 71, 95, 67, 79, 68, 69, 0, 0, 0, 0, 0, 0, 0, 0 };
MemoryStream memoryStream = new MemoryStream(rawData);
using (BsonDataReader bsonDataReader = new BsonDataReader(memoryStream))
{
JsonSerializer jsonSerializer = new JsonSerializer();
String test = jsonSerializer.Deserialize(bsonDataReader).ToString();
}
(byte array brutally initialized for the sake of brevity)
Executing this code produces the following output in the "test" variable:
{
"DefaultReverseRequest4ITTI": {
"orderParams": {
"complexpropertylist": "kAYAAARsaXN0AIUGAAADY29tcGxleHByb3BlcnR5AGk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T0ZGRVJJTkdfQ09ERQAAAAAA"
}
}
}
From my understanding, this is happening because the "complexpropertylist" field contains a byte array itself (maybe base64-encoded?).
So, how can I tell the de-serializer to recursively process every child node?
Any help is sincerely appreciated.
c# json.net bson
I'm writing a C# tool which retrieves and aggregates some data from an Oracle DB and displays it in a clean and readable format.
I came across this VARCHAR column, which contains a BSON stream. I'd like to decode to something human-readable (JSON should do the job).
I'm trying to use Newtonsoft.Json.Bson to de-serialize this stream. I'm using the following code:
byte rawData = new byte { 226, 6, 0, 0, 3, 68, 101, 102, 97, 117, 108, 116, 82, 101, 118, 101, 114, 115, 101, 82, 101, 113, 117, 101, 115, 116, 52, 73, 84, 84, 73, 0, 193, 6, 0, 0, 3, 111, 114, 100, 101, 114, 80, 97, 114, 97, 109, 115, 0, 175, 6, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 108, 105, 115, 116, 0, 144, 6, 0, 0, 0, 144, 6, 0, 0, 4, 108, 105, 115, 116, 0, 133, 6, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 105, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 78, 0, 0, 0, 0, 78, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 11, 0, 0, 0, 51, 51, 52, 49, 50, 56, 52, 52, 57, 52, 0, 2, 99, 111, 100, 101, 0, 7, 0, 0, 0, 77, 83, 73, 83, 68, 78, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 163, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 136, 0, 0, 0, 0, 136, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 65, 0, 0, 0, 51, 55, 56, 50, 122, 85, 68, 68, 89, 67, 56, 57, 114, 104, 99, 76, 78, 57, 48, 101, 71, 56, 74, 113, 52, 122, 66, 75, 87, 97, 119, 50, 69, 69, 67, 120, 106, 105, 57, 118, 115, 110, 103, 86, 117, 79, 86, 73, 71, 77, 88, 106, 48, 77, 79, 53, 120, 83, 55, 65, 84, 50, 114, 56, 0, 2, 99, 111, 100, 101, 0, 11, 0, 0, 0, 77, 101, 115, 115, 97, 103, 101, 83, 101, 113, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 111, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 84, 0, 0, 0, 0, 84, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 7, 0, 0, 0, 79, 112, 67, 111, 100, 101, 0, 2, 99, 111, 100, 101, 0, 17, 0, 0, 0, 67, 95, 79, 80, 69, 82, 65, 84, 73, 79, 78, 95, 67, 79, 68, 69, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 115, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 88, 0, 0, 0, 0, 88, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 9, 0, 0, 0, 79, 112, 82, 101, 97, 115, 111, 110, 0, 2, 99, 111, 100, 101, 0, 19, 0, 0, 0, 67, 95, 79, 80, 69, 82, 65, 84, 73, 79, 78, 95, 82, 69, 65, 83, 79, 78, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 116, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 89, 0, 0, 0, 0, 89, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 13, 0, 0, 0, 67, 108, 105, 101, 110, 116, 83, 117, 98, 83, 121, 115, 0, 2, 99, 111, 100, 101, 0, 16, 0, 0, 0, 67, 95, 67, 76, 73, 69, 78, 84, 95, 83, 85, 66, 83, 89, 83, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 125, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 98, 0, 0, 0, 0, 98, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 14, 0, 0, 0, 67, 108, 105, 101, 110, 116, 70, 105, 110, 73, 110, 102, 111, 0, 2, 99, 111, 100, 101, 0, 24, 0, 0, 0, 67, 95, 67, 76, 73, 69, 78, 84, 95, 70, 73, 78, 65, 78, 67, 73, 65, 76, 95, 73, 78, 70, 79, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 117, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 90, 0, 0, 0, 0, 90, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 15, 0, 0, 0, 50, 48, 49, 56, 49, 50, 50, 56, 49, 53, 51, 57, 50, 50, 0, 2, 99, 111, 100, 101, 0, 15, 0, 0, 0, 79, 80, 69, 82, 65, 84, 73, 79, 78, 95, 68, 65, 84, 69, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 108, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 81, 0, 0, 0, 0, 81, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 16, 0, 0, 0, 50, 50, 50, 48, 49, 51, 51, 52, 49, 50, 56, 52, 52, 57, 52, 0, 2, 99, 111, 100, 101, 0, 5, 0, 0, 0, 73, 77, 83, 73, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 95, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 68, 0, 0, 0, 0, 68, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 3, 0, 0, 0, 51, 56, 0, 2, 99, 111, 100, 101, 0, 5, 0, 0, 0, 80, 82, 79, 70, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 94, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 67, 0, 0, 0, 0, 67, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 2, 0, 0, 0, 80, 0, 2, 99, 111, 100, 101, 0, 5, 0, 0, 0, 84, 89, 80, 69, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 93, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 66, 0, 0, 0, 0, 66, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 2, 0, 0, 0, 48, 0, 2, 99, 111, 100, 101, 0, 4, 0, 0, 0, 68, 79, 77, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 94, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 67, 0, 0, 0, 0, 67, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 2, 0, 0, 0, 49, 0, 2, 99, 111, 100, 101, 0, 5, 0, 0, 0, 83, 86, 73, 83, 0, 0, 0, 3, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 107, 0, 0, 0, 5, 99, 111, 109, 112, 108, 101, 120, 112, 114, 111, 112, 101, 114, 116, 121, 0, 80, 0, 0, 0, 0, 80, 0, 0, 0, 2, 99, 111, 109, 112, 108, 101, 120, 116, 121, 112, 101, 0, 17, 0, 0, 0, 87, 79, 67, 111, 109, 109, 111, 110, 79, 98, 106, 80, 97, 114, 97, 109, 0, 2, 118, 97, 108, 117, 101, 0, 6, 0, 0, 0, 79, 75, 73, 68, 83, 0, 2, 99, 111, 100, 101, 0, 14, 0, 0, 0, 79, 70, 70, 69, 82, 73, 78, 71, 95, 67, 79, 68, 69, 0, 0, 0, 0, 0, 0, 0, 0 };
MemoryStream memoryStream = new MemoryStream(rawData);
using (BsonDataReader bsonDataReader = new BsonDataReader(memoryStream))
{
JsonSerializer jsonSerializer = new JsonSerializer();
String test = jsonSerializer.Deserialize(bsonDataReader).ToString();
}
(byte array brutally initialized for the sake of brevity)
Executing this code produces the following output in the "test" variable:
{
"DefaultReverseRequest4ITTI": {
"orderParams": {
"complexpropertylist": "kAYAAARsaXN0AIUGAAADY29tcGxleHByb3BlcnR5AGkAAAAFY29tcGxleHByb3BlcnR5AE4AAAAATgAAAAJjb21wbGV4dHlwZQARAAAAV09Db21tb25PYmpQYXJhbQACdmFsdWUACwAAADMzNDEyODQ0OTQAAmNvZGUABwAAAE1TSVNETgAAAANjb21wbGV4cHJvcGVydHkAowAAAAVjb21wbGV4cHJvcGVydHkAiAAAAACIAAAAAmNvbXBsZXh0eXBlABEAAABXT0NvbW1vbk9ialBhcmFtAAJ2YWx1ZQBBAAAAMzc4MnpVRERZQzg5cmhjTE45MGVHOEpxNHpCS1dhdzJFRUN4amk5dnNuZ1Z1T1ZJR01YajBNTzV4UzdBVDJyOAACY29kZQALAAAATWVzc2FnZVNlcQAAAANjb21wbGV4cHJv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m9wZXJ0eQBEAAAAAEQAAAACY29tcGxleHR5cGUAEQAAAFdPQ29tbW9uT2JqUGFyYW0AAnZhbHVlAAMAAAAzOAACY29kZQAFAAAAUFJPRgAAAANjb21wbGV4cHJvcGVydHkAXgAAAAVjb21wbGV4cHJvcGVydHkAQwAAAABDAAAAAmNvbXBsZXh0eXBlABEAAABXT0NvbW1vbk9ialBhcmFtAAJ2YWx1ZQACAAAAUAACY29kZQAFAAAAVFlQRQAAAANjb21wbGV4cHJvcGVydHkAXQAAAAVjb21wbGV4cHJvcGVydHkAQgAAAABCAAAAAmNvbXBsZXh0eXBlABEAAABXT0NvbW1vbk9ialBhcmFtAAJ2YWx1ZQACAAAAMAACY29kZQAEAAAARE9NAAAAA2NvbXBsZXhwcm9wZXJ0eQBeAAAABWNvbXBsZXhwcm9wZXJ0eQBDAAAAAEMAAAACY29tcGxleHR5cGUAEQAAAFdPQ29tbW9uT2JqUGFyYW0AAnZhbHVlAAIAAAAxAAJjb2RlAAUAAABTVklTAAAAA2NvbXBsZXhwcm9wZXJ0eQBrAAAABWNvbXBsZXhwcm9wZXJ0eQBQAAAAAFAAAAACY29tcGxleHR5cGUAEQAAAFdPQ29tbW9uT2JqUGFyYW0AAnZhbHVlAAYAAABPS0lEUwACY29kZQAOAAAAT0ZGRVJJTkdfQ09ERQAAAAAA"
}
}
}
From my understanding, this is happening because the "complexpropertylist" field contains a byte array itself (maybe base64-encoded?).
So, how can I tell the de-serializer to recursively process every child node?
Any help is sincerely appreciated.
c# json.net bson
c# json.net bson
asked Dec 28 '18 at 19:35
kleewankleewan
11
11
There's no way to do this automagically, AFAIK. I think you're going to have to write a customJsonConverter
that does this.
– Ian Kemp
Dec 28 '18 at 19:54
By any chance, do you know any article or documentation about doing that? I'm totally new to this library
– kleewan
Dec 28 '18 at 20:40
What is the expected output if everything worked the way you wanted it to?
– Brian Rogers
Dec 28 '18 at 22:56
add a comment |
There's no way to do this automagically, AFAIK. I think you're going to have to write a customJsonConverter
that does this.
– Ian Kemp
Dec 28 '18 at 19:54
By any chance, do you know any article or documentation about doing that? I'm totally new to this library
– kleewan
Dec 28 '18 at 20:40
What is the expected output if everything worked the way you wanted it to?
– Brian Rogers
Dec 28 '18 at 22:56
There's no way to do this automagically, AFAIK. I think you're going to have to write a custom
JsonConverter
that does this.– Ian Kemp
Dec 28 '18 at 19:54
There's no way to do this automagically, AFAIK. I think you're going to have to write a custom
JsonConverter
that does this.– Ian Kemp
Dec 28 '18 at 19:54
By any chance, do you know any article or documentation about doing that? I'm totally new to this library
– kleewan
Dec 28 '18 at 20:40
By any chance, do you know any article or documentation about doing that? I'm totally new to this library
– kleewan
Dec 28 '18 at 20:40
What is the expected output if everything worked the way you wanted it to?
– Brian Rogers
Dec 28 '18 at 22:56
What is the expected output if everything worked the way you wanted it to?
– Brian Rogers
Dec 28 '18 at 22:56
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53963501%2fdecode-bson-stream-to-human-readable-string%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53963501%2fdecode-bson-stream-to-human-readable-string%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
There's no way to do this automagically, AFAIK. I think you're going to have to write a custom
JsonConverter
that does this.– Ian Kemp
Dec 28 '18 at 19:54
By any chance, do you know any article or documentation about doing that? I'm totally new to this library
– kleewan
Dec 28 '18 at 20:40
What is the expected output if everything worked the way you wanted it to?
– Brian Rogers
Dec 28 '18 at 22:56