nolast屬性---精通android、IOS App應用服務程式開發

來源:互聯網
上載者:User

標籤:app   android   ios   代碼   應用   

閉合的json格式內容
同上一博(也可見下邊完整代碼相關部分)

初始化Bag中的記錄
同上一博(也可見下邊完整代碼相關部分)

輸出Bag中的所有記錄,並在數組後邊輸出一個逗號

<for bags=item end="@{item:getLength}">    <item list="@{item:getSuffix}" end="@{item:getLength}" nolast>    <!-- list屬性參數表示輸出為數組列表格式,end屬性參數表示數組結束的位置(跟for的end值相等), nolast屬性參數表示數組後邊輸出一個逗號-->        <name>@{item:name}</name>        <price value>@{item:price}</price><!-- value屬性參數表示輸出不帶引號的值 -->        <unit>@{item:unit}</unit>    </item></for> <tatol>@{item:getLength}</tatol><!-- 前邊的nolast就是用於在這組前邊輸出一個逗號 -->

nolast屬性參數表示數組後邊輸出一個逗號,表示數組後邊還有同層標籤需要輸出

結果

{"items":{"item":[{"name":"馬鈴薯","price":1.24,"unit":"KG"},{"name":"T恤","price":68,"unit":"件"},{"name":"可樂","price":2.20,"unit":"瓶"},{"name":"書","price":51.24,"unit":"本"}],"tatol":"4"}}

完整代碼

{"items":{<chtml><!-- 資料準備部分,您可以從資料庫中查詢 --><bag id=item suffix=0>    <we name=name>馬鈴薯</we>    <we name=price>1.24</we>    <we name=unit>KG</we></bag><bag id=item suffix=1>    <we name=name>T恤</we>    <we name=price>68</we>    <we name=unit>件</we></bag><bag id=item suffix=2>    <we name=name>可樂</we>    <we name=price>2.20</we>    <we name=unit>瓶</we></bag><bag id=item suffix=3>    <we name=name>書</we>    <we name=price>51.24</we>    <we name=unit>本</we></bag></chtml><chtml><!-- 正式json格式的內容 --><for bags=item end="@{item:getLength}">    <item list="@{item:getSuffix}" end="@{item:getLength}" nolast>    <!-- list屬性參數表示輸出為數組列表格式,end屬性參數表示數組結束的位置(跟for的end值相等), nolast屬性參數表示數組後邊輸出一個逗號-->        <name>@{item:name}</name>        <price value>@{item:price}</price><!-- value屬性參數表示輸出不帶引號的值 -->        <unit>@{item:unit}</unit>    </item></for><tatol>@{item:getLength}</tatol><!-- 前邊的nolast就是用於在這組前邊輸出一個逗號 --></chtml>}

例子檔案_samples/app/one_array_nolast.json在輕開平台的_samples/app/目錄下

相關資源下載
移動App應用伺服器開發從入門到精通:http://download.csdn.net/detail/tx18/8741611
快速搭建移動App伺服器 :http://download.csdn.net/detail/tx18/8737507
輕開平台會不定期升級為大家提供更多強大而Easy的功能,請留意下載最新的版本:http://download.csdn.net/user/tx18

nolast屬性---精通android、IOS App應用服務程式開發

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.