package com.ctrip.ops.sysdev.json;

/**
 * Created by liujia on 17/2/10.
 */

import org.joda.time.DateTime;
import org.json.simple.JSONValue;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.util.HashMap;

public class TestJson {
    @Test
    public void testJsonParse() {

    }

    @Test
    public void testJsonDump() {
        HashMap event = new HashMap<String, Object>() {
            {
                put("message", "hello json");
                put("@timestamp", DateTime.parse("2017-03-02T11:15:54+0800"));
            }
        };

        String rst = JSONValue.toJSONString(event);
        Assert.assertEquals(rst, "{\"@timestamp\":\"2017-03-02T11:15:54.000+08:00\",\"message\":\"hello json\"}");
    }
}

@@ -732,16 +732,225 @@
 on%5C%22%7D%22);
+%0A%0A        event.clear();%0A        event.put(%22message%22, %22this is %5C%22hello%5C%22 world%22);%0A        rst = JSONValue.toJSONString(event);%0A        Assert.assertEquals(rst, %22%7B%5C%22message%5C%22:%5C%22this is %5C%5C%5C%22hello%5C%5C%5C%22 world%5C%22%7D%22);
 %0A    %7D%0A%7D

add more test case