Skip to content
Snippets Groups Projects
Commit 48071c5d authored by Alex's avatar Alex
Browse files

Task 4

parent e8c15cfa
No related branches found
No related tags found
No related merge requests found
# Created by https://www.gitignore.io/api/intellij
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
/.idea/ /.idea/
/target/ .idea/workspace.xml
\ No newline at end of file .idea/tasks.xml
.idea/dictionaries
.idea/vcs.xml
.idea/jsLibraryMappings.xml
# Sensitive or high-churn files:
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml
# Gradle:
.idea/gradle.xml
.idea/libraries
# Mongo Explorer plugin:
.idea/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Intellij Patch ###
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
/target/
*.iml
modules.xml
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_15">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: jakarta.json.bind:jakarta.json.bind-api:1.0.1" level="project" />
</component>
</module>
\ No newline at end of file
...@@ -13,23 +13,39 @@ ...@@ -13,23 +13,39 @@
<maven.compiler.target>15</maven.compiler.target> <maven.compiler.target>15</maven.compiler.target>
</properties> </properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>jakarta.json.bind</groupId> <groupId>javax.json.bind</groupId>
<artifactId>jakarta.json.bind-api</artifactId> <artifactId>javax.json.bind-api</artifactId>
<version>1.0.1</version> <version>1.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.json</groupId> <groupId>javax.json</groupId>
<artifactId>javax.json-api</artifactId> <artifactId>javax.json-api</artifactId>
<version>1.1</version> <version>1.1.4</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.glassfish</groupId> <groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId> <artifactId>javax.json</artifactId>
<version>1.1</version> <version>1.1</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.johnzon</groupId>
<artifactId>johnzon-jsonb</artifactId>
<version>1.1.4</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -2,9 +2,9 @@ import java.util.Arrays; ...@@ -2,9 +2,9 @@ import java.util.Arrays;
public class GeoShape { public class GeoShape {
private static final String TYPE = "geoShapes"; public static final String TYPE = "geoShapes";
private String type; public String type;
private double[] coordinates; public double[] coordinates;
public GeoShape(String type, double[] coordinates) { public GeoShape(String type, double[] coordinates) {
this.type = type; this.type = type;
......
import javax.json.Json; import javax.json.Json;
import javax.json.JsonObject; import javax.json.JsonObject;
import javax.json.JsonReader; import javax.json.JsonReader;
import javax.json.JsonValue; import javax.json.JsonValue;
import javax.json.bind.Jsonb;
import javax.json.bind.JsonbBuilder;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
...@@ -9,12 +12,12 @@ public class Main { ...@@ -9,12 +12,12 @@ public class Main {
public static void main(String[] args) throws FileNotFoundException { public static void main(String[] args) throws FileNotFoundException {
//Reading //Task 2
JsonReader reader = Json.createReader(new FileReader("src/main/resources/test.json")); JsonReader reader = Json.createReader(new FileReader("src/main/resources/test.json"));
JsonObject jobj = reader.readObject(); JsonObject jobj = reader.readObject();
System.out.println(jobj); System.out.println(jobj);
//Writing //Task 3
JsonObject writing = Json.createObjectBuilder() JsonObject writing = Json.createObjectBuilder()
.add("type", "events") .add("type", "events")
...@@ -52,9 +55,14 @@ public class Main { ...@@ -52,9 +55,14 @@ public class Main {
.build() .build()
).build()).build()).build()) ).build()).build()).build())
.build(); .build();
System.out.println(writing); System.out.println(writing);
//Task 4
GeoShape geoShape = new GeoShape("geoShapes", new double[]{1000d,223d,121d});
Jsonb jsonb = JsonbBuilder.create();
System.out.println(jsonb.toJson(geoShape));
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment