forked from roytuts/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<project xmlns="https://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.jeejava</groupId> | ||
<artifactId>json-sanitizer</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>json-sanitizer</name> | ||
<url>https://maven.apache.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<jdk.version>1.8</jdk.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- JSON sanitizer --> | ||
<dependency> | ||
<groupId>com.mikesamuel</groupId> | ||
<artifactId>json-sanitizer</artifactId> | ||
<version>1.0</version> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>${jdk.version}</source> | ||
<target>${jdk.version}</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
21 changes: 21 additions & 0 deletions
21
json-sanitizer/src/main/java/com/jeejava/json/sanitizer/JsonSanitizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.jeejava.json.sanitizer; | ||
|
||
public class JsonSanitizer { | ||
|
||
public static String jsonSanitizeOne(String jsonString) { | ||
String wellFormedJson = com.google.json.JsonSanitizer.sanitize(jsonString); | ||
return wellFormedJson; | ||
} | ||
|
||
protected static String jsonSanitizeTwo(String jsonString) { | ||
String wellFormedJson = com.google.json.JsonSanitizer.sanitize(jsonString); | ||
String responseThree = jsonSanitizeThree(jsonString); | ||
System.out.println(responseThree); | ||
return wellFormedJson; | ||
} | ||
|
||
private static String jsonSanitizeThree(String jsonString) { | ||
return jsonString; | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
json-sanitizer/src/main/java/com/jeejava/json/sanitizer/JsonSanitizerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.jeejava.json.sanitizer; | ||
|
||
public class JsonSanitizerTest { | ||
|
||
public static void main(String[] args) { | ||
String jsonString = "{\"key1\":\"value1\",\"type\":\"Booking\",\"sid\":\"A43521\",\"region\":\"ASIA\"," | ||
+ "\"fetchFromFile\":\"false\",\"service\":\"true\",\"isEom\":\"true\",*#@!}"; | ||
|
||
String responseOne = JsonSanitizer.jsonSanitizeOne(jsonString); | ||
System.out.println(responseOne); | ||
|
||
String responseTwo = JsonSanitizer.jsonSanitizeTwo(jsonString); | ||
System.out.println(responseTwo); | ||
} | ||
} |