All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alibaba.rocketmq.research.fastjson.Test Maven / Gradle / Ivy

There is a newer version: 3.1.8
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy