admin
2021-01-04 aa6ef62aef83e277d4171df1d9f0803f91738216
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package com.newvideo.adapter;
 
import java.lang.reflect.Type;
 
import net.sf.json.JSONObject;
 
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.newvideo.domain.web.HotTypeAdmin;
 
public class HotTypeAdminAdapter implements JsonSerializer<HotTypeAdmin>, JsonDeserializer<HotTypeAdmin> {
    // json转为对象时调用,实现JsonDeserializer<PackageState>接口  
    public HotTypeAdmin deserialize(JsonElement json, Type typeOfT,
            JsonDeserializationContext context) throws JsonParseException {
        return null;
    }
    
    // 对象转为Json时调用,实现JsonSerializer<PackageState>接口  
    public JsonElement serialize(HotTypeAdmin src, Type typeOfSrc,
            JsonSerializationContext context) {
        JSONObject data = new JSONObject();
        data.put("hotType", src.getHotType());
        data.put("detailSystemList", src.getDetailSystemList());
        JsonElement json = new JsonPrimitive(data.toString());
        return json;
    }
 
}