Code example for JSONArray

Methods: getlength

0
        if( !( inputNode instanceof JSONArray ) )
        { 
            throw new ValueSerializationException( "Expected an array but got " + inputNode );
        } 
        JSONArray array = (JSONArray) inputNode;
        for( int idx = 0; idx < array.length(); idx++ )
        { 
            Object item = array.get( idx );
            if( !( item instanceof JSONObject ) )
            { 
                throw new ValueSerializationException( "Expected an object but got " + inputNode );
            } 
            JSONObject object = (JSONObject) item;
            Object keyNode = object.get( "key" );
            Object valueNode = object.get( "value" );
            K key = keyDeserializer.map( keyNode );
            V value = valueDeserializer.map( valueNode );
            if( key != null )
            { 
                map.put( key, value );