Default Changelist
This commit is contained in:
		
							
								
								
									
										27
									
								
								src/test/java/com/example/sso/SsoApplicationTests.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								src/test/java/com/example/sso/SsoApplicationTests.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | ||||
| package com.example.sso; | ||||
|  | ||||
| import com.alibaba.fastjson.JSON; | ||||
| import com.alibaba.fastjson.JSONArray; | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import org.junit.Test; | ||||
| import org.springframework.boot.test.context.SpringBootTest; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.HashSet; | ||||
| import java.util.List; | ||||
|  | ||||
|  | ||||
| @SpringBootTest | ||||
| class SsoApplicationTests { | ||||
|  | ||||
|     @Test | ||||
|     void context() { | ||||
|         String json = "[{\"name\":\"1111\",\"code\":\"123\"},{\"name\":\"1111\",\"code\":\"123\"},{\"name\":\"1234\",\"code\":\"111\"}]"; | ||||
|         List list = JSONObject.parseArray(json); | ||||
|         HashSet hs = new HashSet(list); | ||||
|         String jsonSet = JSON.toJSONString(hs); | ||||
|         JSONArray newjsonarray= new JSONArray(Collections.singletonList(jsonSet)); | ||||
|         System.out.println(newjsonarray); | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 lijiazhuo
					lijiazhuo