码迷,mamicode.com
首页 > 移动开发 > 详细

nolast属性---精通android、IOS App应用服务程序开发

时间:2015-06-01 00:51:11      阅读:195      评论:0      收藏:0      [点我收藏+]

标签: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应用服务程序开发

标签:app   android   ios   代码   应用   

原文地址:http://blog.csdn.net/tx18/article/details/46294411

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!