<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jennal's Blog &#187; json_encode</title>
	<atom:link href="http://jennal.cn/tag/json_encode/feed/" rel="self" type="application/rss+xml" />
	<link>http://jennal.cn</link>
	<description>Jennal的技术博客</description>
	<lastBuildDate>Thu, 05 Jan 2012 14:02:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>更新一下我的jlUtil</title>
		<link>http://jennal.cn/2010/02/23/%e6%9b%b4%e6%96%b0%e4%b8%80%e4%b8%8b%e6%88%91%e7%9a%84jlutil/</link>
		<comments>http://jennal.cn/2010/02/23/%e6%9b%b4%e6%96%b0%e4%b8%80%e4%b8%8b%e6%88%91%e7%9a%84jlutil/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 08:50:32 +0000</pubDate>
		<dc:creator>Jennal</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web前台相关]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[json_encode]]></category>

		<guid isPermaLink="false">http://jennal.cn/?p=394</guid>
		<description><![CDATA[修正了几个BUG，已经在实际项目中使用，没有问题。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
Array.prototype.indexOf &#124;&#124; &#40;Array.prototype.indexOf = function&#40;value&#41; &#123;
      for &#40;var i in this&#41; &#123;
          if &#40;this&#91;i&#93; == value&#41; &#123;
              return i;
          [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2009%2F07%2F31%2Fjlutil-for-javascript%2F&from=http%3A%2F%2Fjennal.cn%2F2010%2F02%2F23%2F%25E6%259B%25B4%25E6%2596%25B0%25E4%25B8%2580%25E4%25B8%258B%25E6%2588%2591%25E7%259A%2584jlutil%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">jlUtil For Javascript</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2008%2F12%2F07%2F%25E6%2590%259E%25E5%25AE%259A%25E4%25B8%2580%25E4%25B8%25AA%25E5%25BE%2588%25E7%25BA%25A0%25E7%25BB%2593%25E7%259A%2584json%25E9%2597%25AE%25E9%25A2%2598%25EF%25BC%258C%25E8%25AE%25B0%25E5%25BD%2595%25E4%25B8%2580%25E4%25B8%258B%2F&from=http%3A%2F%2Fjennal.cn%2F2010%2F02%2F23%2F%25E6%259B%25B4%25E6%2596%25B0%25E4%25B8%2580%25E4%25B8%258B%25E6%2588%2591%25E7%259A%2584jlutil%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">搞定一个很纠结的json问题，记录一下</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2010%2F02%2F23%2Fjavascript%25E4%25B8%25AD%25E5%2588%25A4%25E6%2596%25AD%25E5%258F%2598%25E9%2587%258F%25E6%2598%25AF%25E5%2590%25A6%25E4%25B8%25BAarray%2F&from=http%3A%2F%2Fjennal.cn%2F2010%2F02%2F23%2F%25E6%259B%25B4%25E6%2596%25B0%25E4%25B8%2580%25E4%25B8%258B%25E6%2588%2591%25E7%259A%2584jlutil%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">[转]javascript中判断变量是否为array</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2009%2F07%2F18%2Fpro-javascript-techniques-menu%2F&from=http%3A%2F%2Fjennal.cn%2F2010%2F02%2F23%2F%25E6%259B%25B4%25E6%2596%25B0%25E4%25B8%2580%25E4%25B8%258B%25E6%2588%2591%25E7%259A%2584jlutil%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Pro Javascript Techniques – 目录</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>修正了几个BUG，已经在实际项目中使用，没有问题。</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">Array.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">indexOf</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>Array.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">indexOf</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #000066; font-weight: bold;">in</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
          <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> value<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
              <span style="color: #000066; font-weight: bold;">return</span> i<span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
      <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Array.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">remove</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>a <span style="color: #339933;">&gt;=</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">splice</span><span style="color: #009900;">&#40;</span>a<span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
window.<span style="color: #660066;">jlUtil</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
    getJSON<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #339933;">,</span> skip_arr<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> obj <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;number&quot;</span>
        <span style="color: #339933;">||</span> <span style="color: #000066; font-weight: bold;">typeof</span> obj <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;boolean&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span> obj<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> obj <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;string&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;'&quot;</span> <span style="color: #339933;">+</span> obj.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;'&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>'&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;'&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;''&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #003366; font-weight: bold;">var</span> json <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        skip_arr <span style="color: #339933;">=</span> skip_arr <span style="color: #339933;">?</span> skip_arr <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> key <span style="color: #000066; font-weight: bold;">in</span> obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">//skip function and the keys in skip arr</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> obj<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;function&quot;</span>
            <span style="color: #339933;">||</span> skip_arr.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>key<span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">//in Array loop</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>isNaN<span style="color: #009900;">&#40;</span>key<span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> key.<span style="color: #660066;">constructor</span> <span style="color: #339933;">!=</span> String<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                json.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>jlUtil.<span style="color: #660066;">getJSON</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> skip_arr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">//else recurrency</span>
            json.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;'&quot;</span> <span style="color: #339933;">+</span> key <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;':&quot;</span> <span style="color: #339933;">+</span> jlUtil.<span style="color: #660066;">getJSON</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> skip_arr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>Object.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">toString</span>.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'[object Array]'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;[&quot;</span> <span style="color: #339933;">+</span> json.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;,&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;]&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;{&quot;</span> <span style="color: #339933;">+</span> json.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;,&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;}&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    extend<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">length</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> obj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;=</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> dst <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            <span style="color: #006600; font-style: italic;">//extend the rest args to args[0]</span>
            <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> arguments.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> <span style="color: #000066; font-weight: bold;">item</span> <span style="color: #000066; font-weight: bold;">in</span> arguments<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #003366; font-weight: bold;">var</span> tmp <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> arguments<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;object&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #006600; font-style: italic;">//make a copy while is a object, needs jQuery here</span>
                        <span style="color: #003366; font-weight: bold;">var</span> tmp <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> arguments<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                    <span style="color: #006600; font-style: italic;">//if is object try recurrency</span>
                    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>dst<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">typeof</span> dst<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;object&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>dst<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> tmp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                            dst<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> tmp<span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span>
                    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                        dst<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> tmp<span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">return</span> dst<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2009%2F07%2F31%2Fjlutil-for-javascript%2F&from=http%3A%2F%2Fjennal.cn%2F2010%2F02%2F23%2F%25E6%259B%25B4%25E6%2596%25B0%25E4%25B8%2580%25E4%25B8%258B%25E6%2588%2591%25E7%259A%2584jlutil%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">jlUtil For Javascript</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2008%2F12%2F07%2F%25E6%2590%259E%25E5%25AE%259A%25E4%25B8%2580%25E4%25B8%25AA%25E5%25BE%2588%25E7%25BA%25A0%25E7%25BB%2593%25E7%259A%2584json%25E9%2597%25AE%25E9%25A2%2598%25EF%25BC%258C%25E8%25AE%25B0%25E5%25BD%2595%25E4%25B8%2580%25E4%25B8%258B%2F&from=http%3A%2F%2Fjennal.cn%2F2010%2F02%2F23%2F%25E6%259B%25B4%25E6%2596%25B0%25E4%25B8%2580%25E4%25B8%258B%25E6%2588%2591%25E7%259A%2584jlutil%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">搞定一个很纠结的json问题，记录一下</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2010%2F02%2F23%2Fjavascript%25E4%25B8%25AD%25E5%2588%25A4%25E6%2596%25AD%25E5%258F%2598%25E9%2587%258F%25E6%2598%25AF%25E5%2590%25A6%25E4%25B8%25BAarray%2F&from=http%3A%2F%2Fjennal.cn%2F2010%2F02%2F23%2F%25E6%259B%25B4%25E6%2596%25B0%25E4%25B8%2580%25E4%25B8%258B%25E6%2588%2591%25E7%259A%2584jlutil%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">[转]javascript中判断变量是否为array</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2009%2F07%2F18%2Fpro-javascript-techniques-menu%2F&from=http%3A%2F%2Fjennal.cn%2F2010%2F02%2F23%2F%25E6%259B%25B4%25E6%2596%25B0%25E4%25B8%2580%25E4%25B8%258B%25E6%2588%2591%25E7%259A%2584jlutil%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Pro Javascript Techniques – 目录</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://jennal.cn/2010/02/23/%e6%9b%b4%e6%96%b0%e4%b8%80%e4%b8%8b%e6%88%91%e7%9a%84jlutil/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jlUtil For Javascript</title>
		<link>http://jennal.cn/2009/07/31/jlutil-for-javascript/</link>
		<comments>http://jennal.cn/2009/07/31/jlutil-for-javascript/#comments</comments>
		<pubDate>Fri, 31 Jul 2009 01:35:25 +0000</pubDate>
		<dc:creator>Jennal</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Web前台相关]]></category>
		<category><![CDATA[extend]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[json_encode]]></category>

		<guid isPermaLink="false">http://jennal.cn/?p=190</guid>
		<description><![CDATA[昨天用js写了一个Json_encode的工具函数，附上模仿jQuery并加强的extend函数。
对于extend函数，主要加强的是可以遍历子对象来extend，而不是简单的覆盖。
getJSON的使用方法：

jlUtil.getJSON&#40;obj:Object &#91;, skip_arr:Array&#93;&#41;
//skip_arr指定要忽略的键名

extend的使用方法：

jlUtil.extend&#40;obj:Object &#91;, obj2:Object...&#93;&#41;
//这个函数需要jQuery
//如果只带一个参数，则这个obj将被extend到jlUtil本身
//如果带两个以上的参数，则第2个及以后的参数将被extend到第一个参数

下面是代码：

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
var jlUtil = &#123;
	getJSON: function&#40;obj, skip_arr&#41;&#123;
		if&#40;typeof obj == &#34;number&#34;
		&#124;&#124; typeof obj == &#34;boolean&#34;&#41;&#123;
			return obj;
		&#125;else if&#40;typeof obj == &#34;string&#34;&#41;&#123;
			return &#34;'&#34; + obj.replace&#40;&#34;'&#34;,&#34;\\'&#34;&#41; + &#34;'&#34;;
		&#125;
&#160;
		var json = &#91;&#93;;
		skip_arr = skip_arr ? skip_arr : &#91;&#93;;
		for&#40;var key in obj&#41;&#123;
			//skip function and the keys in skip arr
			if&#40;obj&#91;key&#93;.constructor == Function
			&#124;&#124; skip_arr.indexOf&#40;key&#41; != -1&#41;&#123;
				continue;
			&#125;
&#160;
			//in Array loop
			if&#40;!isNaN&#40;parseInt&#40;key&#41;&#41; &#124;&#124; key.constructor [...]<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2008%2F12%2F07%2F%25E6%2590%259E%25E5%25AE%259A%25E4%25B8%2580%25E4%25B8%25AA%25E5%25BE%2588%25E7%25BA%25A0%25E7%25BB%2593%25E7%259A%2584json%25E9%2597%25AE%25E9%25A2%2598%25EF%25BC%258C%25E8%25AE%25B0%25E5%25BD%2595%25E4%25B8%2580%25E4%25B8%258B%2F&from=http%3A%2F%2Fjennal.cn%2F2009%2F07%2F31%2Fjlutil-for-javascript%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">搞定一个很纠结的json问题，记录一下</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2010%2F02%2F23%2F%25E6%259B%25B4%25E6%2596%25B0%25E4%25B8%2580%25E4%25B8%258B%25E6%2588%2591%25E7%259A%2584jlutil%2F&from=http%3A%2F%2Fjennal.cn%2F2009%2F07%2F31%2Fjlutil-for-javascript%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">更新一下我的jlUtil</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2010%2F02%2F23%2Fjavascript%25E4%25B8%25AD%25E5%2588%25A4%25E6%2596%25AD%25E5%258F%2598%25E9%2587%258F%25E6%2598%25AF%25E5%2590%25A6%25E4%25B8%25BAarray%2F&from=http%3A%2F%2Fjennal.cn%2F2009%2F07%2F31%2Fjlutil-for-javascript%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">[转]javascript中判断变量是否为array</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2009%2F07%2F18%2Fpro-javascript-techniques-menu%2F&from=http%3A%2F%2Fjennal.cn%2F2009%2F07%2F31%2Fjlutil-for-javascript%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Pro Javascript Techniques – 目录</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></description>
			<content:encoded><![CDATA[<p>昨天用js写了一个Json_encode的工具函数，附上模仿jQuery并加强的extend函数。<br />
对于extend函数，主要加强的是可以遍历子对象来extend，而不是简单的覆盖。</p>
<p>getJSON的使用方法：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jlUtil.<span style="color: #660066;">getJSON</span><span style="color: #009900;">&#40;</span>obj<span style="color: #339933;">:</span>Object <span style="color: #009900;">&#91;</span><span style="color: #339933;">,</span> skip_arr<span style="color: #339933;">:</span>Array<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
<span style="color: #006600; font-style: italic;">//skip_arr指定要忽略的键名</span></pre></div></div>

<p>extend的使用方法：</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">jlUtil.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>obj<span style="color: #339933;">:</span>Object <span style="color: #009900;">&#91;</span><span style="color: #339933;">,</span> obj2<span style="color: #339933;">:</span>Object...<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
<span style="color: #006600; font-style: italic;">//这个函数需要jQuery</span>
<span style="color: #006600; font-style: italic;">//如果只带一个参数，则这个obj将被extend到jlUtil本身</span>
<span style="color: #006600; font-style: italic;">//如果带两个以上的参数，则第2个及以后的参数将被extend到第一个参数</span></pre></div></div>

<p>下面是代码：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> jlUtil <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	getJSON<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #339933;">,</span> skip_arr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> obj <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;number&quot;</span>
		<span style="color: #339933;">||</span> <span style="color: #000066; font-weight: bold;">typeof</span> obj <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;boolean&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">return</span> obj<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> obj <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;string&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;'&quot;</span> <span style="color: #339933;">+</span> obj.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;'&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>'&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;'&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #003366; font-weight: bold;">var</span> json <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		skip_arr <span style="color: #339933;">=</span> skip_arr <span style="color: #339933;">?</span> skip_arr <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> key <span style="color: #000066; font-weight: bold;">in</span> obj<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #006600; font-style: italic;">//skip function and the keys in skip arr</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">constructor</span> <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">Function</span>
			<span style="color: #339933;">||</span> skip_arr.<span style="color: #660066;">indexOf</span><span style="color: #009900;">&#40;</span>key<span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">//in Array loop</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>isNaN<span style="color: #009900;">&#40;</span>parseInt<span style="color: #009900;">&#40;</span>key<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> key.<span style="color: #660066;">constructor</span> <span style="color: #339933;">!=</span> String<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				json.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>jlUtil.<span style="color: #660066;">getJSON</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> skip_arr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">continue</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
			<span style="color: #006600; font-style: italic;">//else recurrency</span>
			json.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;'&quot;</span> <span style="color: #339933;">+</span> key <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;':&quot;</span> <span style="color: #339933;">+</span> jlUtil.<span style="color: #660066;">getJSON</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#91;</span>key<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> skip_arr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>obj.<span style="color: #660066;">constructor</span> <span style="color: #339933;">==</span> Array<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;[&quot;</span> <span style="color: #339933;">+</span> json.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;,&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;]&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;{&quot;</span> <span style="color: #339933;">+</span> json.<span style="color: #660066;">join</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;,&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;}&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	extend<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">length</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> obj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;=</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> dst <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			<span style="color: #006600; font-style: italic;">//extend the rest args to args[0]</span>
			<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">1</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>arguments.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> <span style="color: #000066; font-weight: bold;">item</span> <span style="color: #000066; font-weight: bold;">in</span> arguments<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
					<span style="color: #003366; font-weight: bold;">var</span> tmp <span style="color: #339933;">=</span> arguments<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
					<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> arguments<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;object&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						<span style="color: #006600; font-style: italic;">//make a copy while is a object, needs jQuery here</span>
						<span style="color: #003366; font-weight: bold;">var</span> tmp <span style="color: #339933;">=</span> $.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> arguments<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
					<span style="color: #006600; font-style: italic;">//if is object try recurrency</span>
					<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>dst<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">typeof</span> dst<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">&quot;object&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
						<span style="color: #000066; font-weight: bold;">try</span><span style="color: #009900;">&#123;</span>
							<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span>dst<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> tmp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
							dst<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> tmp<span style="color: #339933;">;</span>
						<span style="color: #009900;">&#125;</span>
					<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
						dst<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> tmp<span style="color: #339933;">;</span>
					<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000066; font-weight: bold;">return</span> dst<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<table class="wumii-related-items" cellspacing="0" cellpadding="2" border="0" width="100%" style="clear: both;">
    
    <tr>
        <td ><b><font size="-1"  style="display: block !important; padding: 20px 0 5px !important;">您可能也喜欢：</font></b></td>
    </tr>
    
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2008%2F12%2F07%2F%25E6%2590%259E%25E5%25AE%259A%25E4%25B8%2580%25E4%25B8%25AA%25E5%25BE%2588%25E7%25BA%25A0%25E7%25BB%2593%25E7%259A%2584json%25E9%2597%25AE%25E9%25A2%2598%25EF%25BC%258C%25E8%25AE%25B0%25E5%25BD%2595%25E4%25B8%2580%25E4%25B8%258B%2F&from=http%3A%2F%2Fjennal.cn%2F2009%2F07%2F31%2Fjlutil-for-javascript%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">搞定一个很纠结的json问题，记录一下</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2010%2F02%2F23%2F%25E6%259B%25B4%25E6%2596%25B0%25E4%25B8%2580%25E4%25B8%258B%25E6%2588%2591%25E7%259A%2584jlutil%2F&from=http%3A%2F%2Fjennal.cn%2F2009%2F07%2F31%2Fjlutil-for-javascript%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">更新一下我的jlUtil</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2010%2F02%2F23%2Fjavascript%25E4%25B8%25AD%25E5%2588%25A4%25E6%2596%25AD%25E5%258F%2598%25E9%2587%258F%25E6%2598%25AF%25E5%2590%25A6%25E4%25B8%25BAarray%2F&from=http%3A%2F%2Fjennal.cn%2F2009%2F07%2F31%2Fjlutil-for-javascript%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">[转]javascript中判断变量是否为array</font>
                    </a>
                </td>
            </tr>
            <tr>
                <td style="margin: 0 !important; padding: 0 !important; line-height: 20px !important;">
                    <img border="0" src="http://static.wumii.com/images/widget/widget_solidPoint.gif">
                    <a target="_blank" style="text-decoration: none !important;" href="http://app.wumii.com/ext/redirect.htm?url=http%3A%2F%2Fjennal.cn%2F2009%2F07%2F18%2Fpro-javascript-techniques-menu%2F&from=http%3A%2F%2Fjennal.cn%2F2009%2F07%2F31%2Fjlutil-for-javascript%2F">
                        <font size="-1" color="#333333" style="line-height: 1.65em; font-size: 12px !important;">Pro Javascript Techniques – 目录</font>
                    </a>
                </td>
            </tr>
    
    <tr>
        <td  align="right">
            <a style="text-decoration: none !important;" href="http://www.wumii.com/widget/relatedItems.htm" target="_blank" title="无觅相关文章插件">
                <font size="-1" color="#bbbbbb" style="display: block !important; font-family: arial !important; padding: 5px 0 !important; font-size: 12px !important; color: #bbb !important;">无觅</font>
            </a>
        </td>
    </tr>
</table>]]></content:encoded>
			<wfw:commentRss>http://jennal.cn/2009/07/31/jlutil-for-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

