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("{\"@timestamp\":\"2017-03-02T11:15:54.000+08:00\", \"message\":\"hello json\"}", rst);
    }
}

@@ -646,16 +646,21 @@
 tEquals(
+rst, 
 %22%7B%5C%22@tim
@@ -702,17 +702,16 @@
 08:00%5C%22,
- 
 %5C%22messag
@@ -734,13 +734,8 @@
 %5C%22%7D%22
-, rst
 );%0A 

fix typo