Code example for JSONTokener

Methods: next

0
    /** 
     * Tests the next method using expected char. 
     */ 
    public void testNext_ExpectedChar() 
    { 
        jsontokener = new JSONTokener("abc");
        char expectedA = 0;
        try 
        { 
            expectedA = jsontokener.next('a');
            jsontokener.next('c');
            fail("Should have thrown exception.");
        } catch (JSONException e)
        { 
            assertEquals('a', expectedA);
            assertEquals("Expected 'c' and instead saw 'b' at 2 [character 3 line 1]", e.getMessage());
        } 
    } 
 
    /** 
Contextual code suggestions in your IDE  Get Codota for Java