Deserializes an object from JSON - CSharp System.Runtime.Serialization.Json

CSharp examples for System.Runtime.Serialization.Json:Json

Description

Deserializes an object from JSON

Demo Code


using System.Text;
using System.Security.Cryptography;
using System.Net.Http.Formatting;
using System.IO;//from   w ww . j a v a  2s. c  om
using System;

public class Main{
        /// <summary>
		/// Deserializes an object from JSON
		/// </summary>
		/// <typeparam name="T"></typeparam>
		/// <param name="str"></param>
		/// <returns></returns>
		public static T DeserializeFromJson<T>(string str) where T : class
		{
			var json = new JsonMediaTypeFormatter();
			return StringHelper.Deserialize<T>(json, str);
		}
}

Related Tutorials