Nolast attribute --- proficient in Application Development of android and IOS apps, and nolastandroid
Closed json format content
Same as Yibo (see the complete code section below)
Initialize records in the Bag
Same as Yibo (see the complete code section below)
Output all records in the Bag and output a comma behind the Array
<For bags = item end = "@ {item: getLength}"> <item list = "@ {item: getSuffix}" end = "@ {item: getLength} "nolast> <! -- The list attribute parameter indicates that the output is in the array list format, and the end attribute parameter indicates the end position of the array (equal to the end value of ), the nolast attribute parameter indicates that a comma is output after the array --> <name >@{ item: name }</name> <price value >@{ item: price }</price> <! -- Value attribute parameter indicates the output value without quotation marks --> <unit >@{ item: unit} </unit> </item> </for> <tatol >@{ item: getLength} </tatol> <! -- The nolast of the front edge is used to output a comma in the front of the group -->
The nolast attribute parameter indicates that a comma is output after the array, indicating that the same layer labels need to be output after the array.
Result
{"Items": {"item": [{"name": "", "price": 1.24, "unit": "KG" },{ "name ": "T-shirt", "price": 68, "unit": "pieces" },{ "name": "Cola", "price": 2.20, "unit ": "Bottle" },{ "name": "book", "price": 51.24, "unit": "book"}], "tatol": "4 "}}
Complete code
{"Items": {<chtml> <! -- Data preparation, you can query from the database --> <bag id = item suffix = 0> <we name = name> Tudou </we> <we name = price> 1.24 </we> <we name = unit> KG </we> </bag> <bag id = item suffix = 1> <we name = name> T-shirt </we> <we name = price> 68 </we> <we name = unit> pieces </we> </bag> <bag id = item suffix = 2> <we name = name> cola </we> <we name = price> 2.20 </we> <we name = unit> bottle </we> </bag> <bag id = item suffix = 3> <we name = name> book </we> <we name = price> 51.24 </we> <we name = unit> book </we> </Bag> </chtml> <! -- Content in json format --> <for bags = item end = "@ {item: getLength}"> <item list = "@ {item: getSuffix} "end =" @ {item: getLength} "nolast> <! -- The list attribute parameter indicates that the output is in the array list format, and the end attribute parameter indicates the end position of the array (equal to the end value of ), the nolast attribute parameter indicates that a comma is output after the array --> <name >@{ item: name }</name> <price value >@{ item: price }</price> <! -- Value attribute parameter indicates the output value without quotation marks --> <unit >@{ item: unit} </unit> </item> </for> <tatol >@{ item: getLength} </tatol> <! -- The nolast of the front edge is used to output a comma in the front of this group --> </chtml>}
The example file _ samples/app/one_array_nolast.json is in the _ samples/app/directory of the Light-open platform.
Download related resources:
Mobile App server development from entry to entry: http://download.csdn.net/detail/tx18/8741611
Building mobile App server: http://download.csdn.net/detail/tx18/8737507 quickly
Light Open Platform will occasionally upgrade to provide you with more powerful and Easy functions, please pay attention to download the latest version: http://download.csdn.net/user/tx18