com.alibaba.rocketmq.research.fastjson.Test Maven / Gradle / Ivy
package com.alibaba.rocketmq.research.fastjson;
import java.util.concurrent.ConcurrentHashMap;
import com.alibaba.fastjson.JSON;
import com.alibaba.rocketmq.remoting.protocol.RemotingSerializable;
/**
* @author shijia.wxr
* @since 2013-6-18
*/
public class Test {
public static class TestTable {
private final ConcurrentHashMap> testTable =
new ConcurrentHashMap>();
private String remark = "abc";
public ConcurrentHashMap> getTestTable() {
return testTable;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
}
public static void main(String[] args) {
TestTable testTable = new TestTable();
testTable.getTestTable().put("consumer1", new ConcurrentHashMap());
testTable.getTestTable().put("consumer2", new ConcurrentHashMap());
testTable.getTestTable().put("consumer3", new ConcurrentHashMap());
testTable.getTestTable().get("consumer1").put("A", 100L);
testTable.getTestTable().get("consumer1").put("B", 200L);
testTable.getTestTable().get("consumer1").put("C", 300L);
String jsonString = RemotingSerializable.toJson(testTable, true);
String jsonStringFmt = JSON.toJSONString(testTable, true);
System.out.println(jsonString);
System.out.println(jsonStringFmt);
}
}