com.eclipsesource.json.ParseException Java Examples
The following examples show how to use
com.eclipsesource.json.ParseException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ZCashClientCaller.java From zencash-swing-wallet-ui with MIT License | 6 votes |
private JsonValue executeCommandAndGetJsonValue(String command1, String command2, String command3) throws WalletCallException, IOException, InterruptedException { String strResponse = this.executeCommandAndGetSingleStringResponse(command1, command2, command3); JsonValue response = null; try { response = Json.parse(strResponse); } catch (ParseException pe) { throw new WalletCallException(strResponse + "\n" + pe.getMessage() + "\n", pe); } return response; }
Example #2
Source File: R2ServerClient.java From r2cloud with Apache License 2.0 | 6 votes |
private static Long readObservationId(String con) { JsonValue result; try { result = Json.parse(con); } catch (ParseException e) { LOG.info("malformed json"); return null; } if (!result.isObject()) { LOG.info("malformed json"); return null; } JsonObject resultObj = result.asObject(); String status = resultObj.getString("status", null); if (status == null || !status.equalsIgnoreCase("SUCCESS")) { LOG.info("response error: {}", resultObj); return null; } long id = resultObj.getLong("id", -1); if (id == -1) { return null; } return id; }
Example #3
Source File: WebServer.java From r2cloud with Apache License 2.0 | 5 votes |
private static ModelAndView processPost(IHTTPSession session, HttpContoller controller) { ModelAndView model; JsonValue request; try { request = Json.parse(WebServer.getRequestBody(session)); if (!request.isObject()) { model = new BadRequest("expected object"); } else { model = controller.doPost(request.asObject()); } } catch (ParseException e) { model = new BadRequest("expected json object"); } return model; }
Example #4
Source File: ProxyJSONConfigParser.java From dragonite-java with Apache License 2.0 | 5 votes |
public ProxyJSONConfigParser(final String file) throws IOException, JSONConfigException { final String content = new String(Files.readAllBytes(Paths.get(file))); try { this.jsonObject = Json.parse(content).asObject(); } catch (final ParseException | UnsupportedOperationException e) { throw new JSONConfigException("JSON Syntax Error"); } }
Example #5
Source File: JsonValueParser.java From ditto with Eclipse Public License 2.0 | 5 votes |
private static <T> T tryToParseJsonValue(final String jsonString, final DittoJsonHandler<?, ?, T> dittoJsonHandler) { try { return parseJsonValue(jsonString, dittoJsonHandler); } catch (final ParseException | UnsupportedOperationException | StackOverflowError | IllegalArgumentException | NullPointerException e) { // "ditto-json" library also throws IllegalArgumentException when for example strings which may not be empty // (e.g. keys) are empty // "ditto-json" library also throws NullPointerException when for example non-nullable objects are null throw JsonParseException.newBuilder() .message(MessageFormat.format("Failed to parse JSON string ''{0}''!", jsonString)) .cause(e) .build(); } }
Example #6
Source File: JsonValueParser.java From ditto with Eclipse Public License 2.0 | 5 votes |
private static JsonValue tryToReadJsonValueFrom(final Reader reader) { try { return readJsonValueFrom(reader); } catch (final ParseException | IOException | StackOverflowError | IllegalArgumentException | NullPointerException e) { // "ditto-json" library also throws IllegalArgumentException when for example strings which may not be empty // (e.g. keys) are empty // "ditto-json" library also throws NullPointerException when for example non-nullable objects are null throw JsonParseException.newBuilder() .message("Failed to parse JSON value from reader!") .cause(e) .build(); } }
Example #7
Source File: JsonArrayTest.java From ditto with Eclipse Public License 2.0 | 5 votes |
@Test public void tryToGetInstanceOfInvalidValue() { final String[] strings = {"Hallo", "Welt"}; assertThatExceptionOfType(JsonParseException.class) .isThrownBy(() -> JsonArray.of(strings)) .withMessage("Failed to parse JSON string '%s'!", strings.toString()) .withCauseInstanceOf(ParseException.class); }
Example #8
Source File: BannedIPSReader.java From ServerSync with GNU General Public License v3.0 | 5 votes |
public static List<String> read(String data) { try { return fromJson(Json.parse(data).asArray()); } catch (ParseException e) { Logger.debug("Found invalid JSON in string"); } return Collections.emptyList(); }
Example #9
Source File: BannedIPSReader.java From ServerSync with GNU General Public License v3.0 | 5 votes |
public static List<String> read(Path file) throws IOException { try { return fromJson(Json.parse(Files.newBufferedReader(file)).asArray()); } catch (ParseException e) { Logger.debug("Found invalid JSON in banned-ips.json"); } return Collections.emptyList(); }
Example #10
Source File: ProActiveVersionUtilityTest.java From scheduling with GNU Affero General Public License v3.0 | 4 votes |
@Test(expected = ParseException.class) public void testGetProActiveServerVersionStatusCode200InvalidPayload() throws IOException { testGetProActiveServerVersion(200, "Abracadabra", false); }
Example #11
Source File: Mocking_Test.java From minimal-json with MIT License | 4 votes |
@Test public void mockParseException() { Mockito.mock(ParseException.class); }