@@ -78,6 +78,26 @@ public void fromJSON1() throws Exception {
7878 assertEquals (null , d .get (8 ));
7979 }
8080
81+ @ Test
82+ public void fromJSON2 () throws Exception {
83+ String json = "[[1,2,3,\" \u4e2d \" ]]" ;
84+ JSONParser jsonParser = new JSONParser ();
85+ JsonArray jsonArray = (JsonArray ) jsonParser .fromJSON (json );
86+ System .out .println (jsonArray );
87+ }
88+ 89+ @ Test
90+ public void beautifyJSON () throws Exception {
91+ String json = "{\" name\" : \" 狄仁杰\" , \" type\" : \" 射手\" , \" ability\" :[\" 六令追凶\" ,\" 逃脱\" ,\" 王朝密令\" ],\" history\" :{\" DOB\" :630,\" DOD\" :700,\" position\" :\" 宰相\" ,\" dynasty\" :\" 唐朝\" }}" ;
92+ System .out .println ("原 JSON 字符串:" );
93+ System .out .println (json );
94+ System .out .println ("\n " );
95+ System .out .println ("美化后的 JSON 字符串:" );
96+ JSONParser jsonParser = new JSONParser ();
97+ JsonObject drj = (JsonObject ) jsonParser .fromJSON (json );
98+ System .out .println (drj );
99+ }
100+ 81101 private String getJSON () throws IOException {
82102 String url = "http://music.163.com/weapi/v3/playlist/detail" ;
83103 List <BasicNameValuePair > params = new ArrayList <>();
0 commit comments