Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
JSON
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Zanetti Alex (Student Com20)
JSON
Commits
8be774e6
Commit
8be774e6
authored
3 years ago
by
Marco Sciacovelli
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
1b99ac86
e9436a1c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main/java/Event.java
+4
-0
4 additions, 0 deletions
src/main/java/Event.java
src/main/java/GeoShape.java
+18
-1
18 additions, 1 deletion
src/main/java/GeoShape.java
src/main/java/Main.java
+9
-1
9 additions, 1 deletion
src/main/java/Main.java
with
31 additions
and
2 deletions
src/main/java/Event.java
+
4
−
0
View file @
8be774e6
...
...
@@ -19,6 +19,10 @@ public class Event {
public
String
[]
categories
;
public
GeoShape
geometries
;
public
Event
(){
}
public
Event
(
String
id
,
HashMap
<
String
,
String
>
names
,
String
description
,
...
...
This diff is collapsed.
Click to expand it.
src/main/java/GeoShape.java
+
18
−
1
View file @
8be774e6
import
javax.json.bind.serializer.DeserializationContext
;
import
javax.json.bind.serializer.JsonbDeserializer
;
import
javax.json.stream.JsonParser
;
import
java.lang.reflect.Type
;
import
java.util.Arrays
;
public
class
GeoShape
{
public
class
GeoShape
implements
JsonbDeserializer
<
GeoShape
>
{
public
String
type
;
public
double
[][]
coordinates
;
...
...
@@ -12,6 +16,12 @@ public class GeoShape {
this
.
coordinates
[
1
]
=
coordinates2
;
}
public
GeoShape
()
{
}
@Override
public
String
toString
()
{
return
"GeoShape{"
+
...
...
@@ -19,5 +29,12 @@ public class GeoShape {
", coordinates="
+
Arrays
.
toString
(
coordinates
)
+
'}'
;
}
@Override
public
GeoShape
deserialize
(
JsonParser
parser
,
DeserializationContext
ctx
,
Type
rtType
)
{
return
null
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/Main.java
+
9
−
1
View file @
8be774e6
...
...
@@ -55,10 +55,18 @@ public class Main {
.
build
();
System
.
out
.
println
(
writing
);
//JSONB
Jsonb
jsonb
=
JsonbBuilder
.
create
();
//Task 4
GeoShape
geoShape
=
new
GeoShape
(
"geoShapes"
,
new
double
[]{
1000
d
,
223
d
,
121
d
},
new
double
[]{
1000
d
,
223
d
,
121
d
}
);
Jsonb
jsonb
=
JsonbBuilder
.
create
();
System
.
out
.
println
(
jsonb
.
toJson
(
geoShape
));
//Task 6
Event
eve1
=
jsonb
.
fromJson
(
jobj
.
toString
(),
Event
.
class
);
System
.
out
.
println
(
eve1
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment