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

Load() public static method

public static Load ( Stream stream ) : JsonValue
stream System.IO.Stream
return JsonValue
        public static JsonValue Load(Stream stream)
        {
            if (stream == null)
            {
                throw new ArgumentNullException(nameof(stream));
            }

            return Load(new StreamReader(stream, true));
        }

Same methods

JsonValue::Load ( TextReader textReader ) : 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