public void CanConvertString()
        {
            using var fs       = File.Open(GetFileName("JsonFormattedStringString.json"), FileMode.Open, FileAccess.Read, FileShare.Read);
            using var document = JsonDocument.Parse(fs);
            var data = ModelWithBinaryData.DeserializeModelWithBinaryData(document.RootElement);

            Assert.AreEqual("a.value", data.A);
            Assert.AreEqual("1", data.Properties.ToObjectFromJson <string>());
        }
예제 #2
0
        public void DeserializeJsonFormattedStringWithBinaryData()
        {
            using (var fs = new FileStream(GetFileName("JsonFormattedString.json"), FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                using var document = JsonDocument.Parse(fs);
                var data = ModelWithBinaryData.DeserializeModelWithBinaryData(document.RootElement);
                Assert.AreEqual("a.value", data.A);

                var properties = data.Properties.ToDictionaryFromJson();
                Assert.AreEqual("properties.a.value", properties["a"]);
                var innerProperties = properties["innerProperties"] as IDictionary <string, object>;
                Assert.AreEqual("properties.innerProperties.a.value", innerProperties["a"]);
            }
        }