美文网首页
测试代码

测试代码

作者: 沉睡的木木夕 | 来源:发表于2016-08-09 15:00 被阅读0次

    三级标题

    public class JsonHelper
        {
            public static string SerializerObject(object entity)
            {
                if (entity == null)
                    return string.Empty;
                return JsonConvert.SerializeObject(entity);
            }
    
            public static string SerializerObject(object entity, JsonDynamicContractResolver jsonDynamicContractResolver)
            {
                if (entity == null)
                    return string.Empty;
                return JsonConvert.SerializeObject(entity, Formatting.Indented, new JsonSerializerSettings()
                {
                    ContractResolver = jsonDynamicContractResolver
                });
            }
    
            public static string Serializer<T>(T entity) where T : class
            {
                if (entity == null)
                    return string.Empty;
                return JsonConvert.SerializeObject(entity);
            }
    
            public static string Serializer<T>(T entity, JsonDynamicContractResolver jsonDynamicContractResolver) {
                if (entity == null)
                    return string.Empty;
                return JsonConvert.SerializeObject(entity, Formatting.Indented, new JsonSerializerSettings() { 
                    ContractResolver = jsonDynamicContractResolver
                });
            }
    
            public static T Deserializer<T>(string json) where T : class,new() {
                if (String.IsNullOrEmpty(json))
                    return new T();
                return (T)JsonConvert.DeserializeObject<T>(json);
            }
    
            public static T DeserializerAnonymous<T>(string json,T anonymousObj){
                if (String.IsNullOrEmpty(json))
                    throw new ArgumentNullException("json格式不正确且不能为空");
                return (T)JsonConvert.DeserializeAnonymousType(json, anonymousObj);
            }
    
    
            //internal enum JsonFormat
            //{
            //    None = 0,
            //    Indented = 1,
            //}
    
            //internal class JsonSerializerSetting {
            //    public static JsonDynamicContractResolver JsonDynamicContractResolver { get { return } }
            //}
        }
    
    • 无序列表
    1. 有序列表1
    2. 有序列表2

    博客园

    引用:没有什么是钱是搞不定的,如果有,那就是钱不够 ——来自沉睡的木木夕

    这是卸体
    这是粗体

    <p>这是段落</p>

    Tables Area Cool
    默认左对齐 居中 右对齐

    相关文章

      网友评论

          本文标题:测试代码

          本文链接:https://www.haomeiwen.com/subject/tgldsttx.html