System.Json.JsonValue.Load C# (CSharp) Method

Load() public static method

public static Load ( TextReader textReader ) : JsonValue
textReader TextReader
return JsonValue
        public static JsonValue Load(TextReader textReader)
        {
            if (textReader == null)
            {
                throw new ArgumentNullException(nameof(textReader));
            }

            return ToJsonValue(new JavaScriptReader(textReader).Read());
        }

Same methods

JsonValue::Load ( Stream stream ) : JsonValue

Usage Example

Beispiel #1
0
        void ReadAsTest <T>(Random rndGen)
        {
            T instance = InstanceCreator.CreateInstanceOf <T>(rndGen);

            Log.Info("ReadAsTest<{0}>, instance = {1}", typeof(T).Name, instance);
            DataContractJsonSerializer dcjs = new DataContractJsonSerializer(typeof(T));
            JsonValue jv;

            using (MemoryStream ms = new MemoryStream())
            {
                dcjs.WriteObject(ms, instance);
                Log.Info("{0}: {1}", typeof(T).Name, Encoding.UTF8.GetString(ms.ToArray()));
                ms.Position = 0;
                jv          = JsonValue.Load(ms);
            }

            if (instance == null)
            {
                Assert.Null(jv);
            }
            else
            {
                T newInstance = jv.ReadAsType <T>();
                Assert.Equal(instance, newInstance);
            }
        }
All Usage Examples Of System.Json.JsonValue::Load