Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kengao2018
fastjson
提交
c4632d1a
fastjson
项目概览
kengao2018
/
fastjson
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
fastjson
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c4632d1a
编写于
5月 12, 2013
作者:
W
wenshao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bug fixed for TypeReference
上级
78f213b5
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
531 addition
and
83 deletion
+531
-83
pom.xml
pom.xml
+1
-1
src/main/java/com/alibaba/fastjson/parser/DefaultJSONParser.java
...n/java/com/alibaba/fastjson/parser/DefaultJSONParser.java
+1
-1
src/main/java/com/alibaba/fastjson/parser/JSONScanner.java
src/main/java/com/alibaba/fastjson/parser/JSONScanner.java
+5
-11
src/main/java/com/alibaba/fastjson/parser/deserializer/DefaultObjectDeserializer.java
...stjson/parser/deserializer/DefaultObjectDeserializer.java
+4
-3
src/test/java/com/alibaba/json/bvt/ListFieldTest3.java
src/test/java/com/alibaba/json/bvt/ListFieldTest3.java
+56
-0
src/test/java/com/alibaba/json/bvt/TypeReferenceTest6.java
src/test/java/com/alibaba/json/bvt/TypeReferenceTest6.java
+65
-0
src/test/java/com/alibaba/json/bvt/TypeReferenceTest7.java
src/test/java/com/alibaba/json/bvt/TypeReferenceTest7.java
+64
-0
src/test/java/com/alibaba/json/bvt/TypeReferenceTest8.java
src/test/java/com/alibaba/json/bvt/TypeReferenceTest8.java
+64
-0
src/test/java/com/alibaba/json/bvt/TypeReferenceTest9.java
src/test/java/com/alibaba/json/bvt/TypeReferenceTest9.java
+77
-0
src/test/java/com/alibaba/json/bvt/bug/Bug_for_rendong.java
src/test/java/com/alibaba/json/bvt/bug/Bug_for_rendong.java
+57
-54
src/test/java/com/alibaba/json/bvt/parser/deser/IntegerFieldDeserializerTest2.java
.../json/bvt/parser/deser/IntegerFieldDeserializerTest2.java
+21
-13
src/test/java/com/alibaba/json/bvt/parser/deser/LongFieldDeserializerTest2.java
...aba/json/bvt/parser/deser/LongFieldDeserializerTest2.java
+58
-0
src/test/java/com/alibaba/json/bvt/parser/deser/ShortFieldDeserializerTest.java
...aba/json/bvt/parser/deser/ShortFieldDeserializerTest.java
+58
-0
未找到文件。
pom.xml
浏览文件 @
c4632d1a
...
...
@@ -4,7 +4,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.1.31
-SNAPSHOT
</version>
<version>
1.1.31
</version>
<packaging>
jar
</packaging>
<name>
fastjson
</name>
...
...
src/main/java/com/alibaba/fastjson/parser/DefaultJSONParser.java
浏览文件 @
c4632d1a
...
...
@@ -523,7 +523,7 @@ public class DefaultJSONParser extends AbstractJSONParser {
continue
;
}
}
if
(
lexer
.
token
()
==
JSONToken
.
RBRACKET
)
{
break
;
}
...
...
src/main/java/com/alibaba/fastjson/parser/JSONScanner.java
浏览文件 @
c4632d1a
...
...
@@ -1033,7 +1033,7 @@ public final class JSONScanner implements JSONLexer {
}
return
null
;
}
public
String
scanFieldSymbol
(
char
[]
fieldName
,
final
SymbolTable
symbolTable
)
{
matchStat
=
UNKOWN
;
...
...
@@ -2534,16 +2534,10 @@ public final class JSONScanner implements JSONLexer {
}
public
boolean
isEOF
()
{
switch
(
token
)
{
case
JSONToken
.
EOF
:
return
true
;
case
JSONToken
.
ERROR
:
return
false
;
case
JSONToken
.
RBRACE
:
return
false
;
default
:
return
false
;
}
if
(
token
==
JSONToken
.
EOF
)
{
return
true
;
}
return
false
;
}
public
void
close
()
{
...
...
src/main/java/com/alibaba/fastjson/parser/deserializer/DefaultObjectDeserializer.java
浏览文件 @
c4632d1a
...
...
@@ -251,11 +251,12 @@ public class DefaultObjectDeserializer implements ObjectDeserializer {
parser
.
setContext
(
context
,
value
,
key
);
if
(
lexer
.
token
()
==
JSONToken
.
EOF
)
{
final
int
tok
=
lexer
.
token
();
if
(
tok
==
JSONToken
.
EOF
||
tok
==
JSONToken
.
RBRACKET
)
{
return
map
;
}
if
(
lexer
.
token
()
==
JSONToken
.
RBRACE
)
{
if
(
tok
==
JSONToken
.
RBRACE
)
{
lexer
.
nextToken
();
return
map
;
}
...
...
src/test/java/com/alibaba/json/bvt/ListFieldTest3.java
0 → 100644
浏览文件 @
c4632d1a
package
com.alibaba.json.bvt
;
import
java.util.ArrayList
;
import
java.util.List
;
import
junit.framework.TestCase
;
import
com.alibaba.fastjson.JSON
;
import
data.media.MediaContent
;
public
class
ListFieldTest3
extends
TestCase
{
public
void
test_typeRef
()
throws
Exception
{
String
text
=
"{\"images\":[],\"media\":{\"width\":640}}"
;
MediaContent
object
=
JSON
.
parseObject
(
text
,
MediaContent
.
class
);
}
public
static
class
Root
{
private
List
<
Image
>
images
=
new
ArrayList
<
Image
>();
private
Entity
media
;
public
List
<
Image
>
getImages
()
{
return
images
;
}
public
void
setImages
(
List
<
Image
>
images
)
{
this
.
images
=
images
;
}
public
Entity
getMedia
()
{
return
media
;
}
public
void
setMedia
(
Entity
media
)
{
this
.
media
=
media
;
}
}
public
static
class
Image
{
public
int
width
;
}
public
static
class
Entity
{
public
String
title
;
// Can be null
public
int
width
;
public
int
height
;
public
Size
size
;
}
public
enum
Size
{
SMALL
,
LARGE
}
}
src/test/java/com/alibaba/json/bvt/TypeReferenceTest6.java
0 → 100644
浏览文件 @
c4632d1a
package
com.alibaba.json.bvt
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
junit.framework.Assert
;
import
junit.framework.TestCase
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
public
class
TypeReferenceTest6
extends
TestCase
{
public
void
test_typeRef
()
throws
Exception
{
TypeReference
<
Map
<
String
,
Entity
>>
typeRef
=
new
TypeReference
<
Map
<
String
,
Entity
>>()
{
};
Map
<
String
,
Entity
>
map
=
JSON
.
parseObject
(
"{\"value\":{\"id\":\"abc\",\"list\":[{\"id\":123}]}}"
,
typeRef
);
Entity
entity
=
map
.
get
(
"value"
);
Assert
.
assertNotNull
(
entity
);
Assert
.
assertEquals
(
"abc"
,
entity
.
getId
());
Assert
.
assertEquals
(
1
,
entity
.
getList
().
size
());
Assert
.
assertEquals
(
123
,
entity
.
getList
().
get
(
0
).
getId
());
}
public
static
class
Entity
{
private
String
id
;
private
List
<
A
>
list
=
new
ArrayList
<
A
>();
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
List
<
A
>
getList
()
{
return
list
;
}
public
void
setList
(
List
<
A
>
list
)
{
this
.
list
=
list
;
}
}
public
static
class
A
{
private
int
id
;
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
}
}
src/test/java/com/alibaba/json/bvt/TypeReferenceTest7.java
0 → 100644
浏览文件 @
c4632d1a
package
com.alibaba.json.bvt
;
import
java.util.Map
;
import
junit.framework.Assert
;
import
junit.framework.TestCase
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
public
class
TypeReferenceTest7
extends
TestCase
{
public
void
test_typeRef
()
throws
Exception
{
TypeReference
<
Map
<
String
,
Entity
>>
typeRef
=
new
TypeReference
<
Map
<
String
,
Entity
>>()
{
};
Map
<
String
,
Entity
>
map
=
JSON
.
parseObject
(
"{\"value\":{\"id\":\"abc\",\"a\":{\"id\":123}}}"
,
typeRef
);
Entity
entity
=
map
.
get
(
"value"
);
Assert
.
assertNotNull
(
entity
);
Assert
.
assertEquals
(
"abc"
,
entity
.
getId
());
Assert
.
assertEquals
(
123
,
entity
.
getA
().
getId
());
}
public
static
class
Entity
{
private
String
id
;
private
A
a
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
A
getA
()
{
return
a
;
}
public
void
setA
(
A
a
)
{
this
.
a
=
a
;
}
}
public
static
class
A
{
private
int
id
;
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
}
}
src/test/java/com/alibaba/json/bvt/TypeReferenceTest8.java
0 → 100644
浏览文件 @
c4632d1a
package
com.alibaba.json.bvt
;
import
java.util.List
;
import
java.util.Map
;
import
junit.framework.Assert
;
import
junit.framework.TestCase
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
public
class
TypeReferenceTest8
extends
TestCase
{
public
void
test_typeRef
()
throws
Exception
{
TypeReference
<
Map
<
String
,
Entity
>>
typeRef
=
new
TypeReference
<
Map
<
String
,
Entity
>>()
{
};
Map
<
String
,
Entity
>
map
=
JSON
.
parseObject
(
"{\"value\":{\"id\":\"abc\",\"list\":[{\"id\":123}]}}"
,
typeRef
);
Entity
entity
=
map
.
get
(
"value"
);
Assert
.
assertNotNull
(
entity
);
Assert
.
assertEquals
(
"abc"
,
entity
.
getId
());
Assert
.
assertEquals
(
1
,
entity
.
getList
().
length
);
Assert
.
assertEquals
(
123
,
entity
.
getList
()[
0
].
getId
());
}
public
static
class
Entity
{
private
String
id
;
private
A
[]
list
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
A
[]
getList
()
{
return
list
;
}
public
void
setList
(
A
[]
list
)
{
this
.
list
=
list
;
}
}
public
static
class
A
{
private
int
id
;
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
}
}
src/test/java/com/alibaba/json/bvt/TypeReferenceTest9.java
0 → 100644
浏览文件 @
c4632d1a
package
com.alibaba.json.bvt
;
import
java.util.Map
;
import
junit.framework.Assert
;
import
junit.framework.TestCase
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
public
class
TypeReferenceTest9
extends
TestCase
{
public
void
test_typeRef
()
throws
Exception
{
TypeReference
<
Map
<
String
,
Entity
>>
typeRef
=
new
TypeReference
<
Map
<
String
,
Entity
>>()
{
};
Map
<
String
,
Entity
>
map
=
JSON
.
parseObject
(
"{\"value\":{\"id\":\"abc\",\"list\":[{\"id\":123,\"type\":\"A\"}]}}"
,
typeRef
);
Entity
entity
=
map
.
get
(
"value"
);
Assert
.
assertNotNull
(
entity
);
Assert
.
assertEquals
(
"abc"
,
entity
.
getId
());
Assert
.
assertEquals
(
1
,
entity
.
getList
().
length
);
Assert
.
assertEquals
(
123
,
entity
.
getList
()[
0
].
getId
());
}
public
static
class
Entity
{
private
String
id
;
private
A
[]
list
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
A
[]
getList
()
{
return
list
;
}
public
void
setList
(
A
[]
list
)
{
this
.
list
=
list
;
}
}
public
static
class
A
{
private
int
id
;
private
Type
type
;
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
public
Type
getType
()
{
return
type
;
}
public
void
setType
(
Type
type
)
{
this
.
type
=
type
;
}
}
public
static
enum
Type
{
A
}
}
src/test/java/com/alibaba/json/bvt/bug/Bug_for_rendong.java
浏览文件 @
c4632d1a
...
...
@@ -12,78 +12,81 @@ import com.alibaba.fastjson.TypeReference;
public
class
Bug_for_rendong
extends
TestCase
{
public
void
test_0
()
throws
Exception
{
String
text
=
"{\"BX-20110613-1739\":{\"repairNum\":\"BX-20110613-1739\",\"set\":[{\"employNum\":\"a1027\",\"isConfirm\":false,\"isReceive\":false,\"state\":11}]},\"BX-20110613-1749\":{\"repairNum\":\"BX-20110613-1749\",\"set\":[{\"employNum\":\"a1027\",\"isConfirm\":false,\"isReceive\":true,\"state\":1}]}}"
;
Map
<
String
,
TaskMobileStatusBean
>
map
=
JSON
.
parseObject
(
text
,
new
TypeReference
<
Map
<
String
,
TaskMobileStatusBean
>>()
{});
Assert
.
assertEquals
(
2
,
map
.
size
());
//System.out.println(JSON.toJSONString(map, SerializerFeature.PrettyFormat));
}
public
void
test_0
()
throws
Exception
{
String
text
=
"{\"BX-20110613-1739\":{\"repairNum\":\"BX-20110613-1739\",\"set\":[{\"employNum\":\"a1027\",\"isConfirm\":false,\"isReceive\":false,\"state\":11}]},\"BX-20110613-1749\":{\"repairNum\":\"BX-20110613-1749\",\"set\":[{\"employNum\":\"a1027\",\"isConfirm\":false,\"isReceive\":true,\"state\":1}]}}"
;
public
static
class
TaskMobileStatusBean
{
Map
<
String
,
TaskMobileStatusBean
>
map
=
JSON
.
parseObject
(
text
,
new
TypeReference
<
Map
<
String
,
TaskMobileStatusBean
>>()
{
});
private
String
repairNum
;
Assert
.
assertEquals
(
2
,
map
.
size
());
// System.out.println(JSON.toJSONString(map,
// SerializerFeature.PrettyFormat));
}
private
Set
<
PeopleTaskMobileStatusBean
>
set
=
new
HashSet
<
PeopleTaskMobileStatusBean
>();
public
static
class
TaskMobileStatusBean
{
public
String
getRepairNum
()
{
return
repairNum
;
}
private
String
repairNum
;
public
void
setRepairNum
(
String
repairNum
)
{
this
.
repairNum
=
repairNum
;
}
private
Set
<
PeopleTaskMobileStatusBean
>
set
=
new
HashSet
<
PeopleTaskMobileStatusBean
>();
public
Set
<
PeopleTaskMobileStatusBean
>
getSet
()
{
return
set
;
}
public
String
getRepairNum
()
{
return
repairNum
;
}
public
void
setSet
(
Set
<
PeopleTaskMobileStatusBean
>
set
)
{
this
.
set
=
set
;
}
public
void
setRepairNum
(
String
repairNum
)
{
this
.
repairNum
=
repairNum
;
}
}
public
Set
<
PeopleTaskMobileStatusBean
>
getSet
()
{
return
set
;
}
public
static
class
PeopleTaskMobileStatusBean
{
public
void
setSet
(
Set
<
PeopleTaskMobileStatusBean
>
set
)
{
this
.
set
=
set
;
}
private
String
employNum
;
private
Boolean
isConfirm
;
private
Boolean
isReceive
;
private
int
state
;
}
public
String
getEmployNum
()
{
return
employNum
;
}
public
static
class
PeopleTaskMobileStatusBean
{
public
void
setEmployNum
(
String
employNum
)
{
this
.
employNum
=
employNum
;
}
private
String
employNum
;
private
Boolean
isConfirm
;
private
Boolean
isReceive
;
private
int
state
;
public
Boolean
getIsConfir
m
()
{
return
isConfir
m
;
}
public
String
getEmployNu
m
()
{
return
employNu
m
;
}
public
void
setIsConfirm
(
Boolean
isConfir
m
)
{
this
.
isConfirm
=
isConfir
m
;
}
public
void
setEmployNum
(
String
employNu
m
)
{
this
.
employNum
=
employNu
m
;
}
public
Boolean
getIsReceive
()
{
return
isReceive
;
}
public
Boolean
getIsConfirm
()
{
return
isConfirm
;
}
public
void
setIsReceive
(
Boolean
isReceive
)
{
this
.
isReceive
=
isReceive
;
}
public
void
setIsConfirm
(
Boolean
isConfirm
)
{
this
.
isConfirm
=
isConfirm
;
}
public
int
getStat
e
()
{
return
stat
e
;
}
public
Boolean
getIsReceiv
e
()
{
return
isReceiv
e
;
}
public
void
setState
(
int
stat
e
)
{
this
.
state
=
stat
e
;
}
public
void
setIsReceive
(
Boolean
isReceiv
e
)
{
this
.
isReceive
=
isReceiv
e
;
}
}
public
int
getState
()
{
return
state
;
}
public
void
setState
(
int
state
)
{
this
.
state
=
state
;
}
}
}
src/test/java/com/alibaba/json/bvt/parser/deser/IntegerFieldDeserializerTest2.java
浏览文件 @
c4632d1a
package
com.alibaba.json.bvt.parser.deser
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.Map
;
import
org.junit.Assert
;
import
junit.framework.TestCase
;
import
org.junit.Assert
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
public
class
IntegerFieldDeserializerTest2
extends
TestCase
{
protected
void
setUp
()
throws
Exception
{
// ParserConfig.getGlobalInstance().setAsmEnable(false);
}
public
void
test_integer
()
throws
Exception
{
String
text
=
"{\"value\":{\"column1\":\"aa\"
,\"column2\":\"bb\"
}}"
;
String
text
=
"{\"value\":{\"column1\":\"aa\"}}"
;
Map
<
String
,
Entity
>
map
=
JSON
.
parseObject
(
text
,
new
TypeReference
<
Map
<
String
,
Entity
>>(){});
Assert
.
assertNotNull
(
map
);
Assert
.
assertNotNull
(
map
.
get
(
"value"
));
Assert
.
assertNotNull
(
"aa"
,
map
.
get
(
"value"
).
getColumn1
());
Assert
.
assertNotNull
(
"bb"
,
map
.
get
(
"value"
).
getColumn2
());
}
public
void
f_test_integer_2
()
throws
Exception
{
String
text
=
"[{\"value\":{\"column1\":\"aa\"}}]"
;
List
<
Map
<
String
,
Entity
>>
mapList
=
JSON
.
parseObject
(
text
,
new
TypeReference
<
List
<
Map
<
String
,
Entity
>>>(){});
Map
<
String
,
Entity
>
map
=
mapList
.
get
(
0
);
Assert
.
assertNotNull
(
map
);
Assert
.
assertNotNull
(
map
.
get
(
"value"
));
Assert
.
assertNotNull
(
"aa"
,
map
.
get
(
"value"
).
getColumn1
());
}
public
static
class
Entity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
column1
;
private
String
column2
;
private
Integer
column3
;
public
String
getColumn1
()
{
...
...
@@ -35,14 +47,6 @@ public class IntegerFieldDeserializerTest2 extends TestCase {
this
.
column1
=
column1
;
}
public
String
getColumn2
()
{
return
column2
;
}
public
void
setColumn2
(
String
column2
)
{
this
.
column2
=
column2
;
}
public
Integer
getColumn3
()
{
return
column3
;
}
...
...
@@ -51,4 +55,8 @@ public class IntegerFieldDeserializerTest2 extends TestCase {
this
.
column3
=
column3
;
}
}
public
static
class
Value
{
}
}
src/test/java/com/alibaba/json/bvt/parser/deser/LongFieldDeserializerTest2.java
0 → 100644
浏览文件 @
c4632d1a
package
com.alibaba.json.bvt.parser.deser
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.Map
;
import
junit.framework.TestCase
;
import
org.junit.Assert
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
public
class
LongFieldDeserializerTest2
extends
TestCase
{
protected
void
setUp
()
throws
Exception
{
// ParserConfig.getGlobalInstance().setAsmEnable(false);
}
public
void
test_integer
()
throws
Exception
{
String
text
=
"{\"value\":{\"column1\":\"aa\"}}"
;
Map
<
String
,
Entity
>
map
=
JSON
.
parseObject
(
text
,
new
TypeReference
<
Map
<
String
,
Entity
>>(){});
Assert
.
assertNotNull
(
map
);
Assert
.
assertNotNull
(
map
.
get
(
"value"
));
Assert
.
assertNotNull
(
"aa"
,
map
.
get
(
"value"
).
getColumn1
());
}
public
void
test_integer_2
()
throws
Exception
{
String
text
=
"[{\"value\":{\"column1\":\"aa\"}}]"
;
List
<
Map
<
String
,
Entity
>>
mapList
=
JSON
.
parseObject
(
text
,
new
TypeReference
<
List
<
Map
<
String
,
Entity
>>>(){});
Map
<
String
,
Entity
>
map
=
mapList
.
get
(
0
);
Assert
.
assertNotNull
(
map
);
Assert
.
assertNotNull
(
map
.
get
(
"value"
));
Assert
.
assertNotNull
(
"aa"
,
map
.
get
(
"value"
).
getColumn1
());
}
public
static
class
Entity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
column1
;
private
Long
column3
;
public
String
getColumn1
()
{
return
column1
;
}
public
void
setColumn1
(
String
column1
)
{
this
.
column1
=
column1
;
}
public
Long
getColumn3
()
{
return
column3
;
}
public
void
setColumn3
(
Long
column3
)
{
this
.
column3
=
column3
;
}
}
}
src/test/java/com/alibaba/json/bvt/parser/deser/ShortFieldDeserializerTest.java
0 → 100644
浏览文件 @
c4632d1a
package
com.alibaba.json.bvt.parser.deser
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.Map
;
import
junit.framework.TestCase
;
import
org.junit.Assert
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.TypeReference
;
public
class
ShortFieldDeserializerTest
extends
TestCase
{
protected
void
setUp
()
throws
Exception
{
// ParserConfig.getGlobalInstance().setAsmEnable(false);
}
public
void
f_test_integer
()
throws
Exception
{
String
text
=
"{\"value\":{\"column1\":\"aa\"}}"
;
Map
<
String
,
Entity
>
map
=
JSON
.
parseObject
(
text
,
new
TypeReference
<
Map
<
String
,
Entity
>>(){});
Assert
.
assertNotNull
(
map
);
Assert
.
assertNotNull
(
map
.
get
(
"value"
));
Assert
.
assertNotNull
(
"aa"
,
map
.
get
(
"value"
).
getColumn1
());
}
public
void
test_integer_2
()
throws
Exception
{
String
text
=
"[{\"value\":{\"column1\":\"aa\"}}]"
;
List
<
Map
<
String
,
Entity
>>
mapList
=
JSON
.
parseObject
(
text
,
new
TypeReference
<
List
<
Map
<
String
,
Entity
>>>(){});
Map
<
String
,
Entity
>
map
=
mapList
.
get
(
0
);
Assert
.
assertNotNull
(
map
);
Assert
.
assertNotNull
(
map
.
get
(
"value"
));
Assert
.
assertNotNull
(
"aa"
,
map
.
get
(
"value"
).
getColumn1
());
}
public
static
class
Entity
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
column1
;
private
Short
column3
;
public
String
getColumn1
()
{
return
column1
;
}
public
void
setColumn1
(
String
column1
)
{
this
.
column1
=
column1
;
}
public
Short
getColumn3
()
{
return
column3
;
}
public
void
setColumn3
(
Short
column3
)
{
this
.
column3
=
column3
;
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录