package com.mandi.fendan.test; import java.lang.reflect.ParameterizedType; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import org.apache.commons.lang3.StringUtils; import org.junit.Test; import org.springframework.context.ApplicationContext; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.mandi.common.JSONobj; import com.mandi.common.Jacksonmethod; import com.mandi.common.SpringContext; import com.mandi.common.Wxhtmethod; import com.mandi.dao.common.ObjectResult; public class Test1 { @Test public void test_rrd(){ String fhdqNo="120200"; String str=StringUtils.substring(fhdqNo,0, fhdqNo.length()-2); System.err.println(str); } @Test public void test_htt(){ String url="http://10.1.10.101:8089/ws/api/prefix"; Map params=new HashMap(); params.put("action", "123"); List> r=new ArrayList>(); Map mm=new HashMap(); mm.put("abc", 1); mm.put("bcd", "123"); r.add(mm); params.put("data", mm); JsonObject jo=Wxhtmethod.postJsonStr(url,"abc"); System.err.println("jo::::"+jo.toString()); } @Test public void test_jp(){ // list: ["GFTD-18121682","GFTD-18121693","GFTD-18121695"] String list="[\"GFTD-18121682\",\"GFTD-18121693\",\"GFTD-18121695\"]"; JsonParser jp=new JsonParser(); JsonArray ja=jp.parse(list).getAsJsonArray(); for (JsonElement je : ja) { String jes=je.getAsString(); System.err.println("jes::::::::"+jes); } } @Test public void test_getjsobj(){ // list: ["GFTD-18121682","GFTD-18121693","GFTD-18121695"] // {"code":1,"hint":null,"errmsg":null,"item":"XS201812290003"} JsonObject jo=new JsonObject(); jo.addProperty("code", 0); jo.addProperty("item", "XS201812290003"); for (Entry ey : jo.entrySet()) { System.err.println(ey.getKey()+"::::::::"+ey.getValue().getAsString()); } ObjectResult ors=new ObjectResult(); ors=JSONobj.getobj(jo, ors); System.err.println("aaaaaaaaaaa"); // ors=JSONobj.getobj(jo, ors); // System.err.println("a::::::::"+jo); // System.err.println("j::::::::"+Jacksonmethod.tojson(ors, false)); } @Test public void test_getccr(){ } }