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

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

            obj.Verify();
        }
コード例 #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);
        }
コード例 #4
0
            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)));
            }
コード例 #5
0
            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)));
            }
コード例 #6
0
            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)));
            }
コード例 #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)));
            }