0

我有一些要调整的遗留代码。在jsp中有一些对服务器端对象的调用,并且在随后的htm中会在服务器端生成一大块混乱的json。它的格式如下所示。请注意大量的空格等。

这是由客户端 YUI 使用的。

我假设这会有点低效。只是想知道是否有任何关于提高性能的建议。谢谢

ListObject.Data = {
items: [










            {itemID:'a',
            itemType:"b",
            displayName:"c",
            description:"Some text",
            feature:"Asdf",

                date:new Date("Feb 24, 2012"),


            savedBy:"",
            release:"",
            override:"",
            name:"bla"}
            ,
                    ****** lots of more elements *******
     ]
}
4

1 回答 1

1

The only sensible suggestion would be to only send the data you need.

The next best thing you can do is probably to update to YUI 3.9.1. This version started using native JSON when available and the native version is much faster. See http://jsperf.com/json-native-vs-shim

And in the realm of crazier ideas, if your JSON content is too large and it's taking too much time to parse, you could parse it in a Web Worker.

于 2013-05-17T12:46:55.490 回答