Package org.apache.wink.json4j

Examples of org.apache.wink.json4j.JSONArray


     * Test a basic JSON Array construction and helper 'get' function
     */
    public void test_getDoubleNegative() {
        Exception ex = null;
        try {
            JSONArray jArray = new JSONArray("[-1]");
            assertTrue(jArray.getDouble(0) == (double)-1);
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
        assertTrue(ex == null);
View Full Code Here


     * Test a basic JSON Array construction and helper 'get' function
     */
    public void test_getDoubleWithDecimal() {
        Exception ex = null;
        try {
            JSONArray jArray = new JSONArray("[100.959]");
            assertTrue(jArray.getDouble(0) == (double)100.959);
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
        assertTrue(ex == null);
View Full Code Here

     * Test a basic JSON Array construction and helper 'get' function
     */
    public void test_getDoubleNegativeWithDecimal() {
        Exception ex = null;
        try {
            JSONArray jArray = new JSONArray("[-100.959]");
            assertTrue(jArray.getDouble(0) == (double)-100.959);
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
        assertTrue(ex == null);
View Full Code Here

     * Test a basic JSON Array construction and helper 'get' function
     */
    public void test_getDoubleWithExponential() {
        Exception ex = null;
        try {
            JSONArray jArray = new JSONArray("[100959e-3]");
            assertTrue(jArray.getDouble(0) == (double)100.959);
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
        assertTrue(ex == null);
View Full Code Here

     * Test a basic JSON Array construction and helper 'get' function
     */
    public void test_getDoubleNegativeWithExponential() {
        Exception ex = null;
        try {
            JSONArray jArray = new JSONArray("[-100959e-3]");
            assertTrue(jArray.getDouble(0) == (double)-100.959);
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
        assertTrue(ex == null);
View Full Code Here

     * Test a basic JSON Array construction and helper 'get' function
     */
    public void test_getString() {
        Exception ex = null;
        try {
            JSONArray jArray = new JSONArray("[\"some string\"]");
            assertTrue(jArray.getString(0).equals("some string"));
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
        assertTrue(ex == null);
View Full Code Here

     * Test a basic JSON Array construction and helper 'get' function
     */
    public void test_getBoolean() {
        Exception ex = null;
        try {
            JSONArray jArray = new JSONArray("[true]");
            assertTrue(jArray.getBoolean(0));
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
        assertTrue(ex == null);
View Full Code Here

     * Test a basic JSON Array construction and helper 'get' function
     */
    public void test_getBoolean_StringValue() {
        Exception ex = null;
        try {
            JSONArray jArray = new JSONArray("[\"true\"]");
            assertTrue(jArray.getBoolean(0));
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
        assertTrue(ex == null);
View Full Code Here

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

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

     * Test a basic JSON Array construction and helper 'put' function
     */
    public void test_putIntPosition() {
        Exception ex = null;
        try {
            JSONArray jArray = new JSONArray();
            // Put the int at the noted position (1)
            jArray.put(5, 1);
            System.out.println(jArray.toString());

            assertTrue(jArray.size() == 6);
            Integer i = (Integer)jArray.get(5);
            assertTrue(i != null);
            assertTrue(i instanceof java.lang.Integer);
            assertTrue(jArray.getInt(5) == 1);

            // Verify that the 0 position is a null (expanded)
            i = (Integer)jArray.get(3);
            assertTrue(i == null);
            System.out.println(jArray.toString());
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
        assertTrue(ex == null);
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.