Package com.github.nmorel.gwtjackson.client.stream

Examples of com.github.nmorel.gwtjackson.client.stream.JsonReader


            String> bufferedProperties, JsonReader reader, final JsonDeserializationContext ctx, Set<String> ignoredProperties ) {
        if ( null == identityInfo ) {
            return bufferedProperties;
        }

        JsonReader identityReader = null;

        // we look if it has not been already buffered
        String propertyValue = null;

        // we fisrt look if the identity property has not been read already
View Full Code Here


        return read( in, new JsonDeserializationContext.Builder().build() );
    }

    @Override
    public T read( String in, JsonDeserializationContext ctx ) throws JsonDeserializationException {
        JsonReader reader = ctx.newJsonReader( in );

        try {

            if ( ctx.isUnwrapRootValue() ) {

                if ( JsonToken.BEGIN_OBJECT != reader.peek() ) {
                    throw ctx.traceError( "Unwrap root value is enabled but the input is not a JSON Object", reader );
                }
                reader.beginObject();
                if ( JsonToken.END_OBJECT == reader.peek() ) {
                    throw ctx.traceError( "Unwrap root value is enabled but the JSON Object is empty", reader );
                }
                String name = reader.nextName();
                if ( !name.equals( rootName ) ) {
                    throw ctx.traceError( "Unwrap root value is enabled but the name '" + name + "' don't match the expected rootName " +
                            "'" + rootName + "'", reader );
                }
                T result = getDeserializer().deserialize( reader, ctx );
                reader.endObject();
                return result;

            } else {

                return getDeserializer().deserialize( reader, ctx );
View Full Code Here

    public boolean isAcceptSingleValueAsArray() {
        return acceptSingleValueAsArray;
    }

    public JsonReader newJsonReader( String input ) {
        JsonReader reader = new NonBufferedJsonReader( input );
        reader.setLenient( true );
        return reader;
    }
View Full Code Here

        assertNull( deserialize( "null" ) );
    }

    protected T deserialize( String value ) {
        JsonDeserializationContext ctx = new Builder().build();
        JsonReader reader = ctx.newJsonReader( value );
        return createDeserializer().deserialize( reader, ctx );
    }
View Full Code Here

    public JsonReader newJsonReader( String input ) {
        return new DefaultJsonReader( new StringReader( input ) );
    }

    public void testStrictVeryLongNumber() {
        JsonReader reader = newJsonReader( "[0." + repeat( '9', 8192 ) + "]" );
        reader.beginArray();
        try {
            assertEquals( 1d, reader.nextDouble() );
            fail();
        } catch ( MalformedJsonException expected ) {
        }
    }
View Full Code Here

        } catch ( MalformedJsonException expected ) {
        }
    }

    public void testLenientVeryLongNumber() {
        JsonReader reader = newJsonReader( "[0." + repeat( '9', 8192 ) + "]" );
        reader.setLenient( true );
        reader.beginArray();
        assertEquals( JsonToken.STRING, reader.peek() );
        assertEquals( 1d, reader.nextDouble() );
        reader.endArray();
        assertEquals( JsonToken.END_DOCUMENT, reader.peek() );
    }
View Full Code Here

            String> bufferedProperties, JsonReader reader, final JsonDeserializationContext ctx, Set<String> ignoredProperties ) {
        if ( null == identityInfo ) {
            return bufferedProperties;
        }

        JsonReader identityReader = null;

        // we look if it has not been already buffered
        String propertyValue = null;

        // we fisrt look if the identity property has not been read already
View Full Code Here

TOP

Related Classes of com.github.nmorel.gwtjackson.client.stream.JsonReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.