FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-code-example/Framework_JSON/src/EnterPoint.java at master · cherkavi/java-code-example · GitHub
cherkavi
/
java-code-example
Public
Notifications
You must be signed in to change notification settings
Fork
4
Star
0
Code
Issues
0
Pull requests
42
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java-code-example
/
Framework_JSON
/
src
/
EnterPoint.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
35 lines (29 loc) · 1.02 KB
Breadcrumbs
java-code-example
/
Framework_JSON
/
src
/
EnterPoint.java
Copy path
File metadata and controls
executable file
·
35 lines (29 loc) · 1.02 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
import
com
.
google
.
gson
.
Gson
;
/** ïðèìåð èñïîëüçîâàíèÿ JSON - ïðîñëîéêè ìåæäó ðàçëè÷íûìè ÿçûêàìè */
public
class
EnterPoint
{
private
static
void
out
(
Object
value
){
System
.
out
.
println
(
value
);
}
public
static
void
main
(
String
[]
args
){
out
(
"Serialization"
);
Gson
gson
=
new
Gson
();
out
(
"simple int(autopack): "
+
gson
.
toJson
(
1
));
out
(
"string: "
+
gson
.
toJson
(
"abcd"
));
out
(
"long: "
+
gson
.
toJson
(
new
Long
(
10
)));
int
[]
values
= {
1
};
out
(
"array: "
+
gson
.
toJson
(
values
));
out
(
"Deserialization"
);
int
one
=
gson
.
fromJson
(
"1"
,
int
.
class
);
out
(
"one:"
+
one
);
Integer
intOne
=
gson
.
fromJson
(
"1"
,
Integer
.
class
);
out
(
"intOne:"
+
intOne
);
Long
longOne
=
gson
.
fromJson
(
"1"
,
Long
.
class
);
out
(
"longOne:"
+
longOne
);
Boolean
boolValue
=
gson
.
fromJson
(
"false"
,
Boolean
.
class
);
out
(
"boolValue:"
+
boolValue
);
String
str
=
gson
.
fromJson
(
"
\"
abc
\"
"
,
String
.
class
);
out
(
"str:"
+
str
);
String
anotherStr
=
gson
.
fromJson
(
"[
\"
abc
\"
]"
,
String
.
class
);
out
(
"anotherStr: "
+
anotherStr
);
}
}
Back
|
FazBrowse Home
|
New Git URL