JSONTokener toString - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for JSONTokener toString method.

This code example shows how to use the following methods:toString
            } else if (this.jsonValue instanceof JSONStringer) {
                JSONStringer jsonStringer = (JSONStringer) this.jsonValue;
                result = jsonStringer.toString();
            } else if (this.jsonValue instanceof JSONTokener) {
                JSONTokener jsonTokener = (JSONTokener) this.jsonValue;
                result = jsonTokener.toString();
            } 
        } else if (this.jsonRepresentation != null) {
            try { 
                result = this.jsonRepresentation.getText();
            } catch (IOException e) {
                // [ifndef android] instruction 
                throw new JSONException(e);
                // [ifdef android] instruction uncomment 
                // throw new JSONException(e.getMessage()); 
            } 
        } 
 
        return result;
    } 
5
CodeRank
This code example shows how to use the following methods:next, toString
    /** 
     * Tests the next method using line increments on new line. 
     */ 
    public void testNext_LineIncrementsOnNewLine() 
    { 
        jsontokener = new JSONTokener("abc\n123");
        try 
        { 
            jsontokener.next();//a
            jsontokener.next();//b
            jsontokener.next();//c
            assertEquals(" at 3 [character 4 line 1]",jsontokener.toString());
            jsontokener.next();//\n
            assertEquals(" at 4 [character 0 line 2]",jsontokener.toString());
        } catch (JSONException e)
        { 
            fail(e.toString());
        } 
    } 
 
4
CodeRank
This code example shows how to use the following methods:next, toString
 
	/** 
	 * Tests the next method using line increments on new line. 
	 */ 
	public void testNext_LineIncrementsOnNewLine() { 
		jsontokener = new JSONTokener("abc\n123");
		try { 
			jsontokener.next();//a
			jsontokener.next();//b
			jsontokener.next();//c
			assertEquals(" at 3 [character 4 line 1]", jsontokener.toString());
			jsontokener.next();//\n
			assertEquals(" at 4 [character 0 line 2]", jsontokener.toString());
		} catch (JSONException e) {
			fail(e.toString());
		} 
	} 
 
	/** 
	 * Tests the next method using line increments on carriage return. 
4
CodeRank
This code example shows how to use the following methods:toString
            } else if (this.jsonValue instanceof JSONStringer) {
                JSONStringer jsonStringer = (JSONStringer) this.jsonValue;
                result = jsonStringer.toString();
            } else if (this.jsonValue instanceof JSONTokener) {
                JSONTokener jsonTokener = (JSONTokener) this.jsonValue;
                result = jsonTokener.toString();
            } 
        } else if (this.jsonRepresentation != null) {
            try { 
                result = this.jsonRepresentation.getText();
            } catch (IOException e) {
                throw new JSONException(e);
            } 
        } 
 
        return result;
    } 
 
    /** 
     * Gets the wrapped JSON tokener or converts the wrapped representation if 
4
CodeRank
toString Method Overview
Returns the current position and the entire input string.
See Code Examples for other Android JSONTokener Methods: