zoukankan      html  css  js  c++  java
  • 后台反序列化前台传的JSON数据

    using (var stream = Request.InputStream)
                {
                    string inputStream = new StreamReader(stream).ReadToEnd();
                    
                    JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
                    scheduleEventEntity = jsSerializer.Deserialize<ScheduleEventEntity>(inputStream);
                }
     
                foreach (PropertyDescriptor descriptor inTypeDescriptor.GetProperties(scheduleEventEntity))
                {
                    string name = descriptor.Name;
                    object value;
                    if (descriptor.PropertyType == typeof(String))
                    {
                        value =Microsoft.JScript.GlobalObject.unescape(descriptor.GetValue(scheduleEventEntity));
                    }
                    else
                    {
                        value = descriptor.GetValue(scheduleEventEntity);
                    }
                    if (value.ToString() == "undefined")
                    {
                        value = string.Empty;
                    }
                    descriptor.SetValue(scheduleEventEntityvalue);
                }
     
  • 相关阅读:
    Hql语句注意事项总结
    数据库主键设计之思考
    UTF8的中文问题
    DirectShow SDK笔记【关于DirectShow(4)】
    关于kindeditor上传图片出现"服务器发生故障"的解决办法
    php 分隔字符串为数组
    yum 一次性安装 apache mysql php
    linux下安装gd库
    三种实现PHP伪静态页面的方法
    (转)Linux利器 strace
  • 原文地址:https://www.cnblogs.com/Amity/p/2977768.html
Copyright © 2011-2022 走看看