Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
YZG
yzg-util
Commits
c53c65c3
Commit
c53c65c3
authored
Jun 26, 2023
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
表结构修改
parent
fa897f00
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
0 deletions
+25
-0
JsonHelper.java
...src/main/java/com/yanzuoguang/util/helper/JsonHelper.java
+5
-0
TestJson.java
yzg-util-base/src/test/java/helper/TestJson.java
+20
-0
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/JsonHelper.java
View file @
c53c65c3
...
...
@@ -2,6 +2,7 @@ package com.yanzuoguang.util.helper;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
/**
* JSON序列化的处理
...
...
@@ -9,6 +10,10 @@ import com.alibaba.fastjson.TypeReference;
* @author 颜佐光
*/
public
class
JsonHelper
{
static
{
// 全局配置关闭Fastjson循环引用,避免出现$ref
JSON
.
DEFAULT_GENERATE_FEATURE
|=
SerializerFeature
.
DisableCircularReferenceDetect
.
getMask
();
}
/**
* JSON对象开始标记
...
...
yzg-util-base/src/test/java/helper/TestJson.java
0 → 100644
View file @
c53c65c3
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\"}}"
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment