fastjson {"awardId":["JP66640947116481"],"activityId":"HD66670755317350"}
时间: 2024-01-13 21:05:29 浏览: 63
根据提供的引用内容,您可以使用fastjson库将一个JSON字符串解析为Java对象。下面是一个示例代码:
```java
import com.alibaba.fastjson.JSON;
import java.util.List;
public class Main {
public static void main(String[] args) {
String jsonStr = "{\"awardId\":[\"JP66640947116481\"],\"activityId\":\"HD66670755317350\"}";
// 解析JSON字符串
DrawRequest drawRequest = JSON.parseObject(jsonStr, DrawRequest.class);
// 打印解析结果
System.out.println("awardId: " + drawRequest.getAwardId());
System.out.println("activityId: " + drawRequest.getActivityId());
}
}
class DrawRequest {
private List<String> awardId;
private String activityId;
public List<String> getAwardId() {
return awardId;
}
public void setAwardId(List<String> awardId) {
this.awardId = awardId;
}
public String getActivityId() {
return activityId;
}
public void setActivityId(String activityId) {
this.activityId = activityId;
}
}
```
这段代码将会输出以下结果:
```
awardId: [JP66640947116481]
activityId: HD66670755317350
```
阅读全文