Code example for JSONTokener

Methods: next, nextTo

0
    /** 
     * Tests the nextTo method using character. 
     */ 
    public void testNextTo_Character() 
    { 
        jsontokener = new JSONTokener("abc123,test\ntestString1\rsecondString\r\nthird String");
        try 
        { 
            assertEquals("abc123", jsontokener.nextTo(','));
            jsontokener.next(',');
            assertEquals("test", jsontokener.nextTo(','));
            jsontokener.next('\n');
            assertEquals("testString1", jsontokener.nextTo(','));
            jsontokener.next('\r');
            assertEquals("secondString", jsontokener.nextTo(','));
            jsontokener.next('\r');
            jsontokener.next('\n');
            assertEquals("third String", jsontokener.nextTo(','));
        } catch (JSONException e)
        { 
            fail(e.toString());
        } 
    }