package com.alibaba.json.bvt.parser.stream;

import java.io.StringReader;
import java.util.List;

import junit.framework.TestCase;

import org.junit.Assert;

import com.alibaba.fastjson.JSONReader;
import com.alibaba.fastjson.TypeReference;

public class JSONReader_typeRef extends TestCase {
    public void test_array() throws Exception {
        JSONReader reader = new JSONReader(new StringReader("[{\"id\":123}]"));
        
        List<VO> list = reader.readObject(new TypeReference<List<VO>>() {}.getType());
        
        Assert.assertEquals(123, list.get(0).getId());
        
        reader.close();
    }
    
    public void test_array_1() throws Exception {
        JSONReader reader = new JSONReader(new StringReader("[[{\"id\":123}]]"));
        
        reader.startArray();
        List<VO> list = reader.readObject(new TypeReference<List<VO>>() {}.getType());
        
        Assert.assertEquals(123, list.get(0).getId());
        
        reader.endArray();
        
        reader.close();
    }
    
    public static class VO {

        private int id;

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }
    }
}

@@ -1011,32 +1011,423 @@
 e();%0A    %7D%0A    %0A
+    public void test_array_2() throws Exception %7B%0A        JSONReader reader = new JSONReader(new StringReader(%22%5B%5B%7B%5C%22id%5C%22:123%7D%5D%5D%22));%0A        %0A        reader.startArray();%0A        List%3CVO%3E list = reader.readObject(new TypeReference%3CList%3CVO%3E%3E() %7B%7D);%0A        %0A        Assert.assertEquals(123, list.get(0).getId());%0A        %0A        reader.endArray();%0A        %0A        reader.close();%0A    %7D%0A    %0A
     public stati

add testcase