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

闭合的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

  • 7
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 15
    评论
评论 15
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值