FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java/src/test/java/com/jsoniter/TestReflectionDecoder.java at master · ws-php/java · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
ws-php
/
java
Public
forked from
json-iterator/java
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
java
/
src
/
test
/
java
/
com
/
jsoniter
/
TestReflectionDecoder.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (32 loc) · 1.43 KB
Breadcrumbs
java
/
src
/
test
/
java
/
com
/
jsoniter
/
TestReflectionDecoder.java
Copy path
File metadata and controls
41 lines (32 loc) · 1.43 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package
com
.
jsoniter
;
import
com
.
jsoniter
.
spi
.
JsoniterSpi
;
import
junit
.
framework
.
TestCase
;
import
java
.
io
.
IOException
;
public
class
TestReflectionDecoder
extends
TestCase
{
public
static
class
PackageLocal
{
String
field
;
}
public
void
test_package_local
()
throws
IOException
{
JsoniterSpi
.
registerTypeDecoder
(
PackageLocal
.
class
,
ReflectionDecoderFactory
.
create
(
PackageLocal
.
class
));
JsonIterator
iter
=
JsonIterator
.
parse
(
"{'field': 'hello'}"
.
replace
(
'\''
,
'"'
));
PackageLocal
obj
=
iter
.
read
(
PackageLocal
.
class
);
assertEquals
(
"hello"
,
obj
.
field
);
}
public
static
class
Inherited
extends
PackageLocal
{
}
public
void
test_inherited
()
throws
IOException
{
JsoniterSpi
.
registerTypeDecoder
(
Inherited
.
class
,
ReflectionDecoderFactory
.
create
(
Inherited
.
class
));
JsonIterator
iter
=
JsonIterator
.
parse
(
"{'field': 'hello'}"
.
replace
(
'\''
,
'"'
));
Inherited
obj
=
iter
.
read
(
Inherited
.
class
);
assertEquals
(
"hello"
,
obj
.
field
);
}
public
static
class
ObjectWithInt
{
private
int
field
;
}
public
void
test_int_field
()
throws
IOException
{
JsoniterSpi
.
registerTypeDecoder
(
ObjectWithInt
.
class
,
ReflectionDecoderFactory
.
create
(
ObjectWithInt
.
class
));
JsonIterator
iter
=
JsonIterator
.
parse
(
"{'field': 100}"
.
replace
(
'\''
,
'"'
));
ObjectWithInt
obj
=
iter
.
read
(
ObjectWithInt
.
class
);
assertEquals
(
100
,
obj
.
field
);
}
}
Back
|
FazBrowse Home
|
New Git URL