Commit c53c65c3 authored by yanzg's avatar yanzg

表结构修改

parent fa897f00
...@@ -2,6 +2,7 @@ package com.yanzuoguang.util.helper; ...@@ -2,6 +2,7 @@ package com.yanzuoguang.util.helper;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.serializer.SerializerFeature;
/** /**
* JSON序列化的处理 * JSON序列化的处理
...@@ -9,6 +10,10 @@ import com.alibaba.fastjson.TypeReference; ...@@ -9,6 +10,10 @@ import com.alibaba.fastjson.TypeReference;
* @author 颜佐光 * @author 颜佐光
*/ */
public class JsonHelper { public class JsonHelper {
static {
// 全局配置关闭Fastjson循环引用,避免出现$ref
JSON.DEFAULT_GENERATE_FEATURE |= SerializerFeature.DisableCircularReferenceDetect.getMask();
}
/** /**
* JSON对象开始标记 * JSON对象开始标记
......
package helper;
import com.yanzuoguang.util.helper.JsonHelper;
import com.yanzuoguang.util.vo.MapRow;
import org.junit.Assert;
import org.junit.Test;
public class TestJson {
@Test
public void test() throws Exception {
MapRow map1 = new MapRow();
map1.put("m1", "a");
MapRow map = new MapRow();
map.put("k1", map1);
map.put("k2", map1);
String json = JsonHelper.serialize(map);
Assert.assertEquals(json, "{\"k1\":{\"m1\":\"a\"},\"k2\":{\"m1\":\"a\"}}");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment