nice up code
This commit is contained in:
parent
b67eb2c822
commit
e4c03beeea
2 changed files with 4 additions and 8 deletions
|
@ -7,16 +7,13 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I got a really broken pass with invalid json from a user. The source was Virgin Australia
|
* I got a really broken passes with invalid json from users.
|
||||||
* the bad part looked like this:
|
|
||||||
* <p/>
|
|
||||||
* "value": "NTL",}
|
|
||||||
* <p/>
|
|
||||||
* As it is not possible to change the problem in the generator side
|
* As it is not possible to change the problem in the generator side
|
||||||
|
* It has to be worked around here
|
||||||
*/
|
*/
|
||||||
public class SafeJSONReader {
|
public class SafeJSONReader {
|
||||||
|
|
||||||
private static Map<String, String> replacementMap = new LinkedHashMap() {{
|
private static Map<String, String> replacementMap = new LinkedHashMap<String, String>() {{
|
||||||
// first we try without fixing -> always positive and try to have minimal impact
|
// first we try without fixing -> always positive and try to have minimal impact
|
||||||
put("", "");
|
put("", "");
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,7 @@ public class AppleStylePassReader {
|
||||||
|
|
||||||
for (Charset charset : Charset.availableCharsets().values()) {
|
for (Charset charset : Charset.availableCharsets().values()) {
|
||||||
try {
|
try {
|
||||||
|
final String json_str = AXT.at(file).readToString(charset);
|
||||||
String json_str = AXT.at(file).readToString(charset);
|
|
||||||
pass_json = SafeJSONReader.readJSONSafely(json_str);
|
pass_json = SafeJSONReader.readJSONSafely(json_str);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue