Beispiel #1
0
        public static void JsonNodeDeserialize_NonGeneric()
        {
            JsonNode dom = JsonNode.Parse(Json);
            MyPoco   obj = (MyPoco)dom.Deserialize(typeof(MyPoco));

            obj.Verify();
        }
Beispiel #2
0
        public static void JsonNodeDeserialize_Generic()
        {
            JsonNode dom = JsonNode.Parse(Json);
            MyPoco   obj = dom.Deserialize <MyPoco>();

            obj.Verify();
        }
Beispiel #3
0
        public static void SerializeToNode_WithEscaping()
        {
            JsonNode dom = JsonSerializer.SerializeToNode("+");

            Assert.Equal(Escaped_PlusSign, dom.ToJsonString());

            string json = dom.Deserialize <string>();

            Assert.Equal("+", json);
        }
            public override Task <object> DeserializeWrapper(string json, Type type, JsonSerializerContext context)
            {
                if (json is null)
                {
                    // Emulate a null document for API validation tests.
                    return(Task.FromResult(JsonSerializer.Deserialize(node: null, type)));
                }

                JsonNode node = JsonNode.Parse(json);

                return(Task.FromResult(node.Deserialize(type, context)));
            }
            public override Task <T> DeserializeWrapper <T>(string json, JsonTypeInfo <T> jsonTypeInfo)
            {
                if (json is null)
                {
                    // Emulate a null node for API validation tests.
                    return(Task.FromResult(JsonSerializer.Deserialize(node: null, jsonTypeInfo)));
                }

                JsonNode node = JsonNode.Parse(json);

                return(Task.FromResult(node.Deserialize <T>(jsonTypeInfo)));
            }
            public override Task <object> DeserializeWrapper(string json, Type type, JsonSerializerOptions options = null)
            {
                if (json is null)
                {
                    // Emulate a null node for API validation tests.
                    return(Task.FromResult(JsonSerializer.Deserialize(node: null, type, options)));
                }

                JsonNode node = JsonNode.Parse(json, OptionsHelpers.GetNodeOptions(options), OptionsHelpers.GetDocumentOptions(options));

                return(Task.FromResult(node.Deserialize(type, options)));
            }
Beispiel #7
0
            protected internal override Task <object> DeserializeWrapper(string json, Type type, JsonSerializerOptions options = null)
            {
                if (json is null)
                {
                    // Emulate a null node for API validation tests.
                    return(Task.FromResult(JsonSerializer.Deserialize(node: null, type)));
                }

                JsonNode node = JsonNode.Parse(json);

                return(Task.FromResult(node.Deserialize(type, options)));
            }