android.util.MalformedJsonException Java Examples

The following examples show how to use android.util.MalformedJsonException. 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 Project: android-galaxyzoo   Author: murraycu   File:    License: GNU General Public License v3.0 5 votes vote down vote up
public void testLoginWithFailure() throws IOException {
    final MockWebServer server = new MockWebServer();

    //On failure, the server's response code is HTTP_OK,
    //but it has a "success: false" parameter.
    final MockResponse response = new MockResponse();
    response.setBody("test nonsense failure message");

    final ZooniverseClient client = createZooniverseClient(server);

    try {
        final LoginUtils.LoginResult result = client.loginSync("testusername", "testpassword");
    } catch (final ZooniverseClient.LoginException e) {
        assertTrue(e.getCause() instanceof MalformedJsonException);

Example #2
Source Project: 365browser   Author: mogoweb   File:    License: Apache License 2.0 4 votes vote down vote up
private static String sanitizeString(String string) throws MalformedJsonException {
    if (!checkString(string)) {
        throw new MalformedJsonException("Invalid escape sequence");
    return string;