对接中国天气网 城市 id json串

java 代码

package fun;

import java.util.ArrayList;
import java.util.List;

/**
* @author bin
* cape no7
*中国天气网 城市 id 拼PHP json串
*/
public class Php_json {
public static void main(String[] args) {
String str = "北京:101010100朝阳:101010300顺义:101010400怀柔:101010500通州:101010600昌平:101010700延庆:101010800丰台:101010900石景山:101011000大兴:101011100房山:101011200密云:101011300门头沟:101011400平谷:101011500八达岭:101011600佛爷顶:101011700汤河口:101011800密云上甸子:101011900斋堂:101012000霞云岭:101012100北京城区:101012200海淀:101010200天津:101030100宝坻:101030300东丽:101030400西青:101030500北辰:101030600蓟县:101031400汉沽:101030800静海:101030900津南:101031000塘沽:101031100大港:101031200武清:101030200宁河:101030700上海:101020100宝山:101020300嘉定:101020500南汇:101020600浦东:101021300青浦:101020800松江:101020900奉贤:101021000崇明:101021100徐家汇:101021200闵行:101020200金山:101020700石家庄:101090101张家口:101090301承德:101090402唐山:101090501秦皇岛:101091101沧州:101090701衡水:101090801邢台:101090901邯郸:101091001保定:101090201廊坊:101090601郑州:101180101新乡:101180301许昌:101180401平顶山:101180501信阳:101180601南阳:101180701开封:101180801洛阳:101180901商丘:101181001焦作:101181101鹤壁:101181201濮阳:101181301周口:101181401漯河:101181501驻马店:101181601三门峡:101181701济源:101181801安阳:101180201合肥:101220101芜湖:101220301淮南:101220401马鞍山:101220501安庆:101220601宿州:101220701阜阳:101220801亳州:101220901黄山:101221001滁州:101221101淮北:101221201铜陵:101221301宣城:101221401六安:101221501巢湖:101221601池州:101221701蚌埠:101220201杭州:101210101舟山:101211101湖州:101210201嘉兴:101210301金华:101210901绍兴:101210501台州:101210601温州:101210701丽水:101210801衢州:101211001宁波:101210401重庆:101040100合川:101040300南川:101040400江津:101040500万盛:101040600渝北:101040700北碚:101040800巴南:101040900长寿:101041000黔江:101041100万州天城:101041200万州龙宝:101041300涪陵:101041400开县:101041500城口:101041600云阳:101041700巫溪:101041800奉节:101041900巫山:101042000潼南:101042100垫江:101042200梁平:101042300忠县:101042400石柱:101042500大足:101042600荣昌:101042700铜梁:101042800璧山:101042900丰都:101043000武隆:101043100彭水:101043200綦江:101043300酉阳:101043400秀山:101043600沙坪坝:101043700永川:101040200福州:101230101泉州:101230501漳州:101230601龙岩:101230701晋江:101230509南平:101230901厦门:101230201宁德:101230301莆田:101230401三明:101230801兰州:101160101平凉:101160301庆阳:101160401武威:101160501金昌:101160601嘉峪关:101161401酒泉:101160801天水:101160901武都:101161001临夏:101161101合作:101161201白银:101161301定西:101160201张掖:101160701广州:101280101惠州:101280301梅州:101280401汕头:101280501深圳:101280601珠海:101280701佛山:101280800肇庆:101280901湛江:101281001江门:101281101河源:101281201清远:101281301云浮:101281401潮州:101281501东莞:101281601中山:101281701阳江:101281801揭阳:101281901茂名:101282001汕尾:101282101韶关:101280201南宁:101300101柳州:101300301来宾:101300401桂林:101300501梧州:101300601防城港:101301401贵港:101300801玉林:101300901百色:101301001钦州:101301101河池:101301201北海:101301301崇左:101300201贺州:101300701贵阳:101260101安顺:101260301都匀:101260401兴义:101260906铜仁:101260601毕节:101260701六盘水:101260801遵义:101260201凯里:101260501昆明:101290101红河:101290301文山:101290601玉溪:101290701楚雄:101290801普洱:101290901昭通:101291001临沧:101291101怒江:101291201香格里拉:101291301丽江:101291401德宏:101291501景洪:101291601大理:101290201曲靖:101290401保山:101290501呼和浩特:101080101乌海:101080301集宁:101080401通辽:101080501阿拉善左旗:101081201鄂尔多斯:101080701临河:101080801锡林浩特:101080901呼伦贝尔:101081000乌兰浩特:101081101包头:101080201赤峰:101080601南昌:101240101上饶:101240301抚州:101240401宜春:101240501鹰潭:101241101赣州:101240701景德镇:101240801萍乡:101240901新余:101241001九江:101240201吉安:101240601武汉:101200101黄冈:101200501荆州:101200801宜昌:101200901恩施:101201001十堰:101201101神农架:101201201随州:101201301荆门:101201401天门:101201501仙桃:101201601潜江:101201701襄樊:101200201鄂州:101200301孝感:101200401黄石:101200601咸宁:101200701成都:101270101自贡:101270301绵阳:101270401南充:101270501达州:101270601遂宁:101270701广安:101270801巴中:101270901泸州:101271001宜宾:101271101内江:101271201资阳:101271301乐山:101271401眉山:101271501凉山:101271601雅安:101271701甘孜:101271801阿坝:101271901德阳:101272001广元:101272101攀枝花:101270201银川:101170101中卫:101170501固原:101170401石嘴山:101170201吴忠:101170301西宁:101150101黄南:101150301海北:101150801果洛:101150501玉树:101150601海西:101150701海东:101150201海南:101150401济南:101120101潍坊:101120601临沂:101120901菏泽:101121001滨州:101121101东营:101121201威海:101121301枣庄:101121401日照:101121501莱芜:101121601聊城:101121701青岛:101120201淄博:101120301德州:101120401烟台:101120501济宁:101120701泰安:101120801西安:101110101延安:101110300榆林:101110401铜川:101111001商洛:101110601安康:101110701汉中:101110801宝鸡:101110901咸阳:101110200渭南:101110501太原:101100101临汾:101100701运城:101100801朔州:101100901忻州:101101001长治:101100501大同:101100201阳泉:101100301晋中:101100401晋城:101100601吕梁:101101100乌鲁木齐:101130101石河子:101130301昌吉:101130401吐鲁番:101130501库尔勒:101130601阿拉尔:101130701阿克苏:101130801喀什:101130901伊宁:101131001塔城:101131101哈密:101131201和田:101131301阿勒泰:101131401阿图什:101131501博乐:101131601克拉玛依:101130201拉萨:101140101山南:101140301阿里:101140701昌都:101140501那曲:101140601日喀则:101140201林芝:101140401台北县:101340101*:101340201台中:101340401海口:101310101三亚:101310201东方:101310202临高:101310203澄迈:101310204儋州:101310205昌江:101310206白沙:101310207琼中:101310208定安:101310209屯昌:101310210琼海:101310211文昌:101310212保亭:101310214万宁:101310215陵水:101310216西沙:101310217南沙岛:101310220乐东:101310221五指山:101310222琼山:101310102长沙:101250101株洲:101250301衡阳:101250401郴州:101250501常德:101250601益阳:101250700娄底:101250801邵阳:101250901岳阳:101251001张家界:101251101怀化:101251201黔阳:101251301永州:101251401吉首:101251501湘潭:101250201南京:101190101镇江:101190301苏州:101190401南通:101190501扬州:101190601宿迁:101191301徐州:101190801淮安:101190901连云港:101191001常州:101191101泰州:101191201无锡:101190201盐城:101190701哈尔滨:101050101牡丹江:101050301佳木斯:101050401绥化:101050501黑河:101050601双鸭山:101051301伊春:101050801大庆:101050901七台河:101051002鸡西:101051101鹤岗:101051201齐齐哈尔:101050201大兴安岭:101050701长春:101060101延吉:101060301四平:101060401白山:101060901白城:101060601辽源:101060701*:101060801吉林:101060201通化:101060501沈阳:101070101鞍山:101070301抚顺:101070401本溪:101070501丹东:101070601葫芦岛:101071401营口:101070801阜新:101070901辽阳:101071001铁岭:101071101朝阳:101071201盘锦:101071301大连:101070201锦州:101070701";
String[] city = str.split(":");
String res = new String();
List all = new ArrayList();


for (int i = 0; i < city.length; i++) {
if(!(i == 0)){
List one = new ArrayList();
String id = "\"";
String area = "\"";
for (int j = 0; j < city[i].length(); j++) {
if(!(‘a‘< city[i].charAt(j) && ‘9‘ < city[i].charAt(j))){
id += ""+city[i].charAt(j)+"";
}else{
area += ""+city[i].charAt(j)+"";
}

}
id += "\",";
area += "\"=>";
one.add(id);
one.add(area);
all.add(one);
}
}

res += "array{\"北京\"=>";
for (int y = 0; y < all.size(); y++) {
List temp = (List) all.get(y);
res += temp.get(0)+"\n";
res += temp.get(1);
}
res = res.substring(0, res.length()-4);
res = res +"}";
System.out.println(res);
}
}

 

得到PHP json串

array{"北京"=>"101010100",
"朝阳"=>"101010300",
"顺义"=>"101010400",
"怀柔"=>"101010500",
"通州"=>"101010600",
"昌平"=>"101010700",
"延庆"=>"101010800",
"丰台"=>"101010900",
"石景山"=>"101011000",
"大兴"=>"101011100",
"房山"=>"101011200",
"密云"=>"101011300",
"门头沟"=>"101011400",
"平谷"=>"101011500",
"八达岭"=>"101011600",
"佛爷顶"=>"101011700",
"汤河口"=>"101011800",
"密云上甸子"=>"101011900",
"斋堂"=>"101012000",
"霞云岭"=>"101012100",
"北京城区"=>"101012200",
"海淀"=>"101010200",
"天津"=>"101030100",
"宝坻"=>"101030300",
"东丽"=>"101030400",
"西青"=>"101030500",
"北辰"=>"101030600",
"蓟县"=>"101031400",
"汉沽"=>"101030800",
"静海"=>"101030900",
"津南"=>"101031000",
"塘沽"=>"101031100",
"大港"=>"101031200",
"武清"=>"101030200",
"宁河"=>"101030700",
"上海"=>"101020100",
"宝山"=>"101020300",
"嘉定"=>"101020500",
"南汇"=>"101020600",
"浦东"=>"101021300",
"青浦"=>"101020800",
"松江"=>"101020900",
"奉贤"=>"101021000",
"崇明"=>"101021100",
"徐家汇"=>"101021200",
"闵行"=>"101020200",
"金山"=>"101020700",
"石家庄"=>"101090101",
"张家口"=>"101090301",
"承德"=>"101090402",
"唐山"=>"101090501",
"秦皇岛"=>"101091101",
"沧州"=>"101090701",
"衡水"=>"101090801",
"邢台"=>"101090901",
"邯郸"=>"101091001",
"保定"=>"101090201",
"廊坊"=>"101090601",
"郑州"=>"101180101",
"新乡"=>"101180301",
"许昌"=>"101180401",
"平顶山"=>"101180501",
"信阳"=>"101180601",
"南阳"=>"101180701",
"开封"=>"101180801",
"洛阳"=>"101180901",
"商丘"=>"101181001",
"焦作"=>"101181101",
"鹤壁"=>"101181201",
"濮阳"=>"101181301",
"周口"=>"101181401",
"漯河"=>"101181501",
"驻马店"=>"101181601",
"三门峡"=>"101181701",
"济源"=>"101181801",
"安阳"=>"101180201",
"合肥"=>"101220101",
"芜湖"=>"101220301",
"淮南"=>"101220401",
"马鞍山"=>"101220501",
"安庆"=>"101220601",
"宿州"=>"101220701",
"阜阳"=>"101220801",
"亳州"=>"101220901",
"黄山"=>"101221001",
"滁州"=>"101221101",
"淮北"=>"101221201",
"铜陵"=>"101221301",
"宣城"=>"101221401",
"六安"=>"101221501",
"巢湖"=>"101221601",
"池州"=>"101221701",
"蚌埠"=>"101220201",
"杭州"=>"101210101",
"舟山"=>"101211101",
"湖州"=>"101210201",
"嘉兴"=>"101210301",
"金华"=>"101210901",
"绍兴"=>"101210501",
"台州"=>"101210601",
"温州"=>"101210701",
"丽水"=>"101210801",
"衢州"=>"101211001",
"宁波"=>"101210401",
"重庆"=>"101040100",
"合川"=>"101040300",
"南川"=>"101040400",
"江津"=>"101040500",
"万盛"=>"101040600",
"渝北"=>"101040700",
"北碚"=>"101040800",
"巴南"=>"101040900",
"长寿"=>"101041000",
"黔江"=>"101041100",
"万州天城"=>"101041200",
"万州龙宝"=>"101041300",
"涪陵"=>"101041400",
"开县"=>"101041500",
"城口"=>"101041600",
"云阳"=>"101041700",
"巫溪"=>"101041800",
"奉节"=>"101041900",
"巫山"=>"101042000",
"潼南"=>"101042100",
"垫江"=>"101042200",
"梁平"=>"101042300",
"忠县"=>"101042400",
"石柱"=>"101042500",
"大足"=>"101042600",
"荣昌"=>"101042700",
"铜梁"=>"101042800",
"璧山"=>"101042900",
"丰都"=>"101043000",
"武隆"=>"101043100",
"彭水"=>"101043200",
"綦江"=>"101043300",
"酉阳"=>"101043400",
"秀山"=>"101043600",
"沙坪坝"=>"101043700",
"永川"=>"101040200",
"福州"=>"101230101",
"泉州"=>"101230501",
"漳州"=>"101230601",
"龙岩"=>"101230701",
"晋江"=>"101230509",
"南平"=>"101230901",
"厦门"=>"101230201",
"宁德"=>"101230301",
"莆田"=>"101230401",
"三明"=>"101230801",
"兰州"=>"101160101",
"平凉"=>"101160301",
"庆阳"=>"101160401",
"武威"=>"101160501",
"金昌"=>"101160601",
"嘉峪关"=>"101161401",
"酒泉"=>"101160801",
"天水"=>"101160901",
"武都"=>"101161001",
"临夏"=>"101161101",
"合作"=>"101161201",
"白银"=>"101161301",
"定西"=>"101160201",
"张掖"=>"101160701",
"广州"=>"101280101",
"惠州"=>"101280301",
"梅州"=>"101280401",
"汕头"=>"101280501",
"深圳"=>"101280601",
"珠海"=>"101280701",
"佛山"=>"101280800",
"肇庆"=>"101280901",
"湛江"=>"101281001",
"江门"=>"101281101",
"河源"=>"101281201",
"清远"=>"101281301",
"云浮"=>"101281401",
"潮州"=>"101281501",
"东莞"=>"101281601",
"中山"=>"101281701",
"阳江"=>"101281801",
"揭阳"=>"101281901",
"茂名"=>"101282001",
"汕尾"=>"101282101",
"韶关"=>"101280201",
"南宁"=>"101300101",
"柳州"=>"101300301",
"来宾"=>"101300401",
"桂林"=>"101300501",
"梧州"=>"101300601",
"防城港"=>"101301401",
"贵港"=>"101300801",
"玉林"=>"101300901",
"百色"=>"101301001",
"钦州"=>"101301101",
"河池"=>"101301201",
"北海"=>"101301301",
"崇左"=>"101300201",
"贺州"=>"101300701",
"贵阳"=>"101260101",
"安顺"=>"101260301",
"都匀"=>"101260401",
"兴义"=>"101260906",
"铜仁"=>"101260601",
"毕节"=>"101260701",
"六盘水"=>"101260801",
"遵义"=>"101260201",
"凯里"=>"101260501",
"昆明"=>"101290101",
"红河"=>"101290301",
"文山"=>"101290601",
"玉溪"=>"101290701",
"楚雄"=>"101290801",
"普洱"=>"101290901",
"昭通"=>"101291001",
"临沧"=>"101291101",
"怒江"=>"101291201",
"香格里拉"=>"101291301",
"丽江"=>"101291401",
"德宏"=>"101291501",
"景洪"=>"101291601",
"大理"=>"101290201",
"曲靖"=>"101290401",
"保山"=>"101290501",
"呼和浩特"=>"101080101",
"乌海"=>"101080301",
"集宁"=>"101080401",
"通辽"=>"101080501",
"阿拉善左旗"=>"101081201",
"鄂尔多斯"=>"101080701",
"临河"=>"101080801",
"锡林浩特"=>"101080901",
"呼伦贝尔"=>"101081000",
"乌兰浩特"=>"101081101",
"包头"=>"101080201",
"赤峰"=>"101080601",
"南昌"=>"101240101",
"上饶"=>"101240301",
"抚州"=>"101240401",
"宜春"=>"101240501",
"鹰潭"=>"101241101",
"赣州"=>"101240701",
"景德镇"=>"101240801",
"萍乡"=>"101240901",
"新余"=>"101241001",
"九江"=>"101240201",
"吉安"=>"101240601",
"武汉"=>"101200101",
"黄冈"=>"101200501",
"荆州"=>"101200801",
"宜昌"=>"101200901",
"恩施"=>"101201001",
"十堰"=>"101201101",
"神农架"=>"101201201",
"随州"=>"101201301",
"荆门"=>"101201401",
"天门"=>"101201501",
"仙桃"=>"101201601",
"潜江"=>"101201701",
"襄樊"=>"101200201",
"鄂州"=>"101200301",
"孝感"=>"101200401",
"黄石"=>"101200601",
"咸宁"=>"101200701",
"成都"=>"101270101",
"自贡"=>"101270301",
"绵阳"=>"101270401",
"南充"=>"101270501",
"达州"=>"101270601",
"遂宁"=>"101270701",
"广安"=>"101270801",
"巴中"=>"101270901",
"泸州"=>"101271001",
"宜宾"=>"101271101",
"内江"=>"101271201",
"资阳"=>"101271301",
"乐山"=>"101271401",
"眉山"=>"101271501",
"凉山"=>"101271601",
"雅安"=>"101271701",
"甘孜"=>"101271801",
"阿坝"=>"101271901",
"德阳"=>"101272001",
"广元"=>"101272101",
"攀枝花"=>"101270201",
"银川"=>"101170101",
"中卫"=>"101170501",
"固原"=>"101170401",
"石嘴山"=>"101170201",
"吴忠"=>"101170301",
"西宁"=>"101150101",
"黄南"=>"101150301",
"海北"=>"101150801",
"果洛"=>"101150501",
"玉树"=>"101150601",
"海西"=>"101150701",
"海东"=>"101150201",
"海南"=>"101150401",
"济南"=>"101120101",
"潍坊"=>"101120601",
"临沂"=>"101120901",
"菏泽"=>"101121001",
"滨州"=>"101121101",
"东营"=>"101121201",
"威海"=>"101121301",
"枣庄"=>"101121401",
"日照"=>"101121501",
"莱芜"=>"101121601",
"聊城"=>"101121701",
"青岛"=>"101120201",
"淄博"=>"101120301",
"德州"=>"101120401",
"烟台"=>"101120501",
"济宁"=>"101120701",
"泰安"=>"101120801",
"西安"=>"101110101",
"延安"=>"101110300",
"榆林"=>"101110401",
"铜川"=>"101111001",
"商洛"=>"101110601",
"安康"=>"101110701",
"汉中"=>"101110801",
"宝鸡"=>"101110901",
"咸阳"=>"101110200",
"渭南"=>"101110501",
"太原"=>"101100101",
"临汾"=>"101100701",
"运城"=>"101100801",
"朔州"=>"101100901",
"忻州"=>"101101001",
"长治"=>"101100501",
"大同"=>"101100201",
"阳泉"=>"101100301",
"晋中"=>"101100401",
"晋城"=>"101100601",
"吕梁"=>"101101100",
"乌鲁木齐"=>"101130101",
"石河子"=>"101130301",
"昌吉"=>"101130401",
"吐鲁番"=>"101130501",
"库尔勒"=>"101130601",
"阿拉尔"=>"101130701",
"阿克苏"=>"101130801",
"喀什"=>"101130901",
"伊宁"=>"101131001",
"塔城"=>"101131101",
"哈密"=>"101131201",
"和田"=>"101131301",
"阿勒泰"=>"101131401",
"阿图什"=>"101131501",
"博乐"=>"101131601",
"克拉玛依"=>"101130201",
"拉萨"=>"101140101",
"山南"=>"101140301",
"阿里"=>"101140701",
"昌都"=>"101140501",
"那曲"=>"101140601",
"日喀则"=>"101140201",
"林芝"=>"101140401",
"台北县"=>"101340101",
"*"=>"101340201",
"台中"=>"101340401",
"海口"=>"101310101",
"三亚"=>"101310201",
"东方"=>"101310202",
"临高"=>"101310203",
"澄迈"=>"101310204",
"儋州"=>"101310205",
"昌江"=>"101310206",
"白沙"=>"101310207",
"琼中"=>"101310208",
"定安"=>"101310209",
"屯昌"=>"101310210",
"琼海"=>"101310211",
"文昌"=>"101310212",
"保亭"=>"101310214",
"万宁"=>"101310215",
"陵水"=>"101310216",
"西沙"=>"101310217",
"南沙岛"=>"101310220",
"乐东"=>"101310221",
"五指山"=>"101310222",
"琼山"=>"101310102",
"长沙"=>"101250101",
"株洲"=>"101250301",
"衡阳"=>"101250401",
"郴州"=>"101250501",
"常德"=>"101250601",
"益阳"=>"101250700",
"娄底"=>"101250801",
"邵阳"=>"101250901",
"岳阳"=>"101251001",
"张家界"=>"101251101",
"怀化"=>"101251201",
"黔阳"=>"101251301",
"永州"=>"101251401",
"吉首"=>"101251501",
"湘潭"=>"101250201",
"南京"=>"101190101",
"镇江"=>"101190301",
"苏州"=>"101190401",
"南通"=>"101190501",
"扬州"=>"101190601",
"宿迁"=>"101191301",
"徐州"=>"101190801",
"淮安"=>"101190901",
"连云港"=>"101191001",
"常州"=>"101191101",
"泰州"=>"101191201",
"无锡"=>"101190201",
"盐城"=>"101190701",
"哈尔滨"=>"101050101",
"牡丹江"=>"101050301",
"佳木斯"=>"101050401",
"绥化"=>"101050501",
"黑河"=>"101050601",
"双鸭山"=>"101051301",
"伊春"=>"101050801",
"大庆"=>"101050901",
"七台河"=>"101051002",
"鸡西"=>"101051101",
"鹤岗"=>"101051201",
"齐齐哈尔"=>"101050201",
"大兴安岭"=>"101050701",
"长春"=>"101060101",
"延吉"=>"101060301",
"四平"=>"101060401",
"白山"=>"101060901",
"白城"=>"101060601",
"辽源"=>"101060701",
"*"=>"101060801",
"吉林"=>"101060201",
"通化"=>"101060501",
"沈阳"=>"101070101",
"鞍山"=>"101070301",
"抚顺"=>"101070401",
"本溪"=>"101070501",
"丹东"=>"101070601",
"葫芦岛"=>"101071401",
"营口"=>"101070801",
"阜新"=>"101070901",
"辽阳"=>"101071001",
"铁岭"=>"101071101",
"朝阳"=>"101071201",
"盘锦"=>"101071301",
"大连"=>"101070201",
"锦州"=>"101070701",
}

对接中国天气网 城市 id json串

上一篇:jsp 小脚本


下一篇:Js template engine