Package com.alibaba.json.bvt.parser

Source Code of com.alibaba.json.bvt.parser.TypeUtilsToJSONTest$User

package com.alibaba.json.bvt.parser;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

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

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

@SuppressWarnings("rawtypes")
public class TypeUtilsToJSONTest extends TestCase {

    public void test_0() throws Exception {
        HashMap map = new HashMap();

        JSONObject json = (JSONObject) JSON.toJSON(map);

        Assert.assertEquals(map.size(), json.size());
    }

    public void test_1() throws Exception {
        List list = new ArrayList();

        JSONArray json = (JSONArray) JSON.toJSON(list);

        Assert.assertEquals(list.size(), json.size());
    }

    public void test_null() throws Exception {
        Assert.assertEquals(null, JSON.toJSON(null));
    }

    public static class User {

        private long   id;
        private String name;

        public long getId() {
            return id;
        }

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

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }
}
TOP

Related Classes of com.alibaba.json.bvt.parser.TypeUtilsToJSONTest$User

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.