Package org.apache.wink.json4j

Examples of org.apache.wink.json4j.JSONArray


     */
    public void test_getDouble_typeMisMatchNull() {
        Exception ex = null;

        try {
            JSONArray jArray = new JSONArray("[null]");
            assertTrue(jArray.getDouble(0) == (double)1);
        } catch (Exception ex1) {
            ex = ex1;
        }
        assertTrue(ex instanceof JSONException);
    }
View Full Code Here


     */
    public void test_getString_typeMisMatchNull() {
        Exception ex = null;

        try {
            JSONArray jArray = new JSONArray("[null]");
            assertTrue(jArray.getString(0) == "1");
        } catch (Exception ex1) {
            ex = ex1;
        }
        assertTrue(ex instanceof JSONException);
    }
View Full Code Here

     */
    public void test_getBoolean_typeMisMatchNull() {
        Exception ex = null;

        try {
            JSONArray jArray = new JSONArray("[null]");
            assertTrue(jArray.getBoolean(0) == true);
        } catch (Exception ex1) {
            ex = ex1;
        }
        assertTrue(ex instanceof JSONException);
    }
View Full Code Here

     * Test a 'join' of a JSONArray
     */
    public void test_JoinNoDelimiter() {
        Exception ex = null;
        try {
            JSONArray jArray = new JSONArray("[1, true, false, null, \"My String\", [1,2,3], {\"foo\":\"bar\"}]");
            String joined = jArray.join("");
            assertTrue(joined.equals("1truefalsenullMy String[1,2,3]{\"foo\":\"bar\"}"));
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

     * Test a 'join' of a JSONArray
     */
    public void test_JoinDelimiter() {
        Exception ex = null;
        try {
            JSONArray jArray = new JSONArray("[1, true, false, null, \"My String\", [1,2,3], {\"foo\":\"bar\"}]");
            String joined = jArray.join("|");
            assertTrue(joined.equals("1|true|false|null|My String|[1,2,3]|{\"foo\":\"bar\"}"));
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

     */
    public void test_Date() {
        Exception ex = null;
        try{
            Date date = new Date();
            JSONArray ja = new JSONArray();
            ja.put(date);
            JSONObject jsonDate = ja.getJSONObject(0);
            assertTrue(jsonDate instanceof JSONObject);
            assertTrue(jsonDate.get("class").equals("java.util.Date"));
            System.out.println(ja.write(3));
        } catch (Exception ex1){
            ex = ex1;
            ex.printStackTrace();
        }
        assertTrue(ex == null);
View Full Code Here

            JSONStringer jStringer = new JSONStringer();
            jStringer.array();
            jStringer.endArray();
            String str = jStringer.toString();
            // Verify it parses.
            JSONArray test = new JSONArray(str);
            assertTrue(str.equals("[]"));
        }catch(Exception ex1){
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

            jStringer.endArray();

            String str = jStringer.toString();

            // Verify it parses.
            JSONArray test = new JSONArray(str);
            assertTrue(str.equals("[\"String1\",false,1,{\"string\":\"String2\"},[1,2.0,3]]"));
        }catch(Exception ex1){
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

            is.close();
            String expected="\u592a\u548c\u6bbf";
            JSONObject search = (JSONObject)jObject.get("search");
            JSONObject payload = (JSONObject)search.get("payLoad");
            JSONObject ssug = (JSONObject)payload.get("sSug");
            JSONArray items = (JSONArray)ssug.get("item");

            for (int i = 0; i <items.size(); i++) {
                String str = (String)items.get(i);
                assertTrue(expected.equals(str));
            }
        } catch (Exception ex1) {
            ex1.printStackTrace();
            ex = ex1;
View Full Code Here

    /**
     * Test the noargs contructor.
     */
    public void test_new() {
        JSONArray jObject = new JSONArray();
        assertTrue(jObject != null);
        assertTrue(jObject.length() == 0);
    }
View Full Code Here

TOP

Related Classes of org.apache.wink.json4j.JSONArray

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.