shikeying
2024-01-11 3b67e947e36133e2a40eb2737b15ea375e157ea0
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
package com.walker.push.rocketmq;
 
import com.walker.infrastructure.utils.DateUtils;
import com.walker.infrastructure.utils.JsonUtils;
import com.walker.push.rocketmq.tcp.MqResponse;
import org.junit.Test;
 
import java.util.HashMap;
import java.util.Map;
 
public class MqResponseSerialize {
 
    @Test
    public void testSerialize() throws Exception{
        Map<String, Object> map = new HashMap<>(2);
        map.put("protocolNum", "data");
        map.put("name", "0");
 
        MqResponse mqResponse = new MqResponse();
        mqResponse.setTopic("myTopic");
        mqResponse.setSendTime(DateUtils.getDateTimeNumber());
        mqResponse.setKey("123456");
        mqResponse.setResponse(JsonUtils.objectToJsonString(map));
 
        String json = JsonUtils.objectToJsonString(mqResponse);
        System.out.println("json = " + json);
 
        MqResponse data = JsonUtils.jsonStringToObject(json, MqResponse.class);
        System.out.println("response = " + data.getResponse());
    }
}