相关疑难解决方法(0)

更改ASP MVC3中使用的默认JSON序列化程序

我有一个控制器将大型JSON对象返回到jQuery Flot,我想知道用ServiceStack.Text中的那个更快地替换默认的JavaScriptSerializer是多么容易.

如果我可以使用DependencyResolver更改这样的东西会很好,但我想如果一切都解决了,那么它可能会变得很慢.

asp.net-mvc serialization json asp.net-mvc-3

17
推荐指数
2
解决办法
2万
查看次数

创建 JSON 响应时如何忽略属性(如果属性为 null)?

我有 1 个类,如下所示:

public class Tables
    {
        public string Name { get; set; }
        public string[] Columns { get; set; }
    }

string[] selectedTables = { "Table1", "Table2"};
using (var conection = new SqlConnection("MyconnectionString"))
{
    connection.Open();

    var tables = (
        from table in connection.GetSchema("Tables").AsEnumerable()
        let name = (string)table["TABLE_NAME"]
        where selectedTables.Contains(name)
        let catalog = (string)table["TABLE_CATALOG"]
        let schema = (string)table["TABLE_SCHEMA"]
        select new Tables // this should really be called Table
        {
            Name = name,
            Columns = (
                from column in connection.GetSchema("Columns", new …
Run Code Online (Sandbox Code Playgroud)

.net c# linq json

0
推荐指数
1
解决办法
2343
查看次数

C#Json结合了两个不同的对象

我需要有一个这种格式的json(当数据为null时,只需检索时间字段):

var chartData = [
            {
                "time": "0",
                "value": -0.307
            },
            {
                "time": "1",
                "value": -0.168
            },
            {
                "time": "2"
            },
            {
                "time": "3",
                "value": -0.027
            }
]
Run Code Online (Sandbox Code Playgroud)

我创建了两个类:

  • dataV1(时间)
  • dataV2(时间,值 - >应该是双倍)

码:

public class dataV1
{
    public string time { get; set; }

    public dataV1(string Ptime)
    {
        this.time = Ptime;      
    }

    public dataV1() { }
}

public class dataV2
{
    public string time { get; set; }
    public double value { get; set; }

    public dataV2(string Ptime, double …
Run Code Online (Sandbox Code Playgroud)

c# json

-1
推荐指数
1
解决办法
641
查看次数

标签 统计

json ×3

c# ×2

.net ×1

asp.net-mvc ×1

asp.net-mvc-3 ×1

linq ×1

serialization ×1