Package com.alibaba.json.bvt

Source Code of com.alibaba.json.bvt.MaterializedInterfaceTest2$Bean

package com.alibaba.json.bvt;

import junit.framework.Assert;
import junit.framework.TestCase;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.util.TypeUtils;

public class MaterializedInterfaceTest2 extends TestCase {
   
    public void test_parse() throws Exception {
        String text = "{\"id\":123, \"name\":\"chris\"}";
        JSONObject object = JSON.parseObject(text);
       
        Bean bean = TypeUtils.cast(object, Bean.class, null);
       
        Assert.assertEquals(123, bean.getId());
        Assert.assertEquals("chris", bean.getName());
       
        String text2 = JSON.toJSONString(bean);
        System.out.println(text2);
    }

    public static interface Bean {
        int getId();

        void setId(int value);

        String getName();

        void setName(String value);
    }
}
TOP

Related Classes of com.alibaba.json.bvt.MaterializedInterfaceTest2$Bean

TOP
Copyright © 2018 www.massapi.com. 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.