Created
August 9, 2013 00:43
-
-
Save adison/6190247 to your computer and use it in GitHub Desktop.
generate json, json like data by Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
this code tis purposed to make data for AngularJS from data kind of | |
province district | |
data-A1 data-B1 | |
data-A1 data-B2 | |
data-A1 data-B3 | |
to | |
[province: "data-A1", districts: [ | |
{distict: "data-B1"}, | |
{distict: "data-B2"}, | |
{distict: "data-B3"} | |
]] | |
*/ | |
while(vRs.next()){ | |
// 是否同一組 | |
if(!vCurrectCountyID.equals(vRs.getString("province")) | |
|| vCurrectCountyID.equals("")){ | |
vCurrectCountyID = vRs.getString("province"); | |
vCurrentCountyName = vRs.getString("city_name"); | |
if(countyCounter !=0) | |
vRegionModel += "]},"; | |
countyCounter ++; | |
vRegionModel += "{cName: '" + vCurrentCountyName + "', cID: '" + vCurrectCountyID + "',diss: [{dID:'0', dName:'全區'},"; | |
} else | |
vRegionModel += ","; | |
vRegionModel += "{dID: '" + vRs.getString("areacode").trim() + "', dName:'" + vRs.getString("area_name").trim() +"'}"; | |
} | |
vRegionModel.substring(0, vRegionModel.length()-2); | |
vRegionModel += "]}];"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment