小编dum*_*dum的帖子

使用JSON.NET解析嵌套的JSON对象

我的JSON提要有嵌套对象,如下所示:

{
"id": 1765116,
"name": "StrozeR",
"birth": "2009-08-12",
"avatar": "http:\/\/static.erepublik.com\/uploads\/avatars\/Citizens\/2009\/08\/12\/f19db99e9baddad73981d214a6e576ef_100x100.jpg",
"online": true,
"alive": true,
"ban": null,
"level": 61,
"experience": 183920,
"strength": 25779.42,
"rank": {
    "points": 133687587,
    "level": 63,
    "image": "http:\/\/www.erepublik.com\/images\/modules\/ranks\/god_of_war_1.png",
    "name": "God of War*"
},
"elite_citizen": false,
"national_rank": 6,
"residence": {
    "country": {
        "id": 81,
        "name": "Republic of China (Taiwan)",
        "code": "TW"
    },
    "region": {
        "id": 484,
        "name": "Hokkaido"
    }
}
}
Run Code Online (Sandbox Code Playgroud)

我的对象类是这样的:

class Citizen
{
    public class Rank
    {
        public int points { get; set; }
        public int level …
Run Code Online (Sandbox Code Playgroud)

c# json json.net deserialization

12
推荐指数
1
解决办法
3万
查看次数

如何使用数组扩展jquery插件的选项

我正在写一个jQuery插件.有一些默认选项,我可以在HTML上更改它们,但如果它包含一个数组,如何更改选项?

这是插件中的代码:

(function($){    
    $.fn.extend({  
        aniTag: function(options) {     
            var defaults = {
                radius: 25,
                defaultradius: 0,
                enableTilt: true,
                tilt : 20,
                random : true, 
                randomMax : 25 ,
            };

            var colors = new Array('4AC7ED', 'FDC015', '9F78EC', 'F25C33');         

            var options = $.extend(defaults, options); 

            return this.each(function() {                
                var o = options;
                //some stuff
            });
        }
    });  
})(jQuery);
Run Code Online (Sandbox Code Playgroud)

这是html用法:

<script type="text/javascript">
    $(document).ready(function() {
        $('.tags').aniTag({enableTilt: false});
    });
</script>
Run Code Online (Sandbox Code Playgroud)

如你所见,我可以改变enableTilt选项.我需要做的是更改color数组中的值.是的,我知道我需要将该数组放入defaultsvar中,但我不知道该怎么做.

arrays jquery

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

标签 统计

arrays ×1

c# ×1

deserialization ×1

jquery ×1

json ×1

json.net ×1