Package org.apache.wink.json4j

Examples of org.apache.wink.json4j.JSONObject.opt()


    public void test_newFromBeanWithOutSuper() {
        Exception ex = null;
        try {
            Date date = new Date();
            JSONObject ja = new JSONObject(date, false);
            assertTrue(ja.opt("class") == null);
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
        assertTrue(ex == null);
View Full Code Here


            assertEquals( jObject.opt("int").getClass(), Integer.class);
            assertEquals( jObject2.opt("int").getClass(), Integer.class);
            assertEquals( jObject3.opt("int").getClass(), Integer.class);
            assertEquals( jObject4.opt("int").getClass(), Integer.class);
            assertEquals( jObject5.opt("int").getClass(), Integer.class);
            assertEquals( jObject6.opt("int").getClass(), Integer.class);

        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

            JSONObject jObject3 = new JSONObject("{\"int\" : 0X" + Long.toHexString(val1.longValue()) + "}");
            JSONObject jObject4 = new JSONObject("{\"int\" : 020000000000}");
            assertEquals( jObject.opt("int").getClass(), Long.class);
            assertEquals( jObject2.opt("int").getClass(), Long.class);
            assertEquals( jObject3.opt("int").getClass(), Long.class);
            assertEquals( jObject4.opt("int").getClass(), Long.class);

        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

    public void test_optWithHex() {
        Exception ex = null;

          try {
            JSONObject jObject3 = new JSONObject("{\"int\" : 0X7f}");
            assertEquals( jObject3.opt("int"), 127);
            jObject3 = new JSONObject("{\"int\" : 0x7f}");
            assertEquals( jObject3.opt("int"), 127);
            jObject3 = new JSONObject("{\"int\" : -0x99e}");
            assertEquals( jObject3.opt("int"), -2462);
            jObject3 = new JSONObject("{\"int\" : -0X99e}");
View Full Code Here

          try {
            JSONObject jObject3 = new JSONObject("{\"int\" : 0X7f}");
            assertEquals( jObject3.opt("int"), 127);
            jObject3 = new JSONObject("{\"int\" : 0x7f}");
            assertEquals( jObject3.opt("int"), 127);
            jObject3 = new JSONObject("{\"int\" : -0x99e}");
            assertEquals( jObject3.opt("int"), -2462);
            jObject3 = new JSONObject("{\"int\" : -0X99e}");
            assertEquals( jObject3.opt("int"), -2462);
View Full Code Here

            JSONObject jObject3 = new JSONObject("{\"int\" : 0X7f}");
            assertEquals( jObject3.opt("int"), 127);
            jObject3 = new JSONObject("{\"int\" : 0x7f}");
            assertEquals( jObject3.opt("int"), 127);
            jObject3 = new JSONObject("{\"int\" : -0x99e}");
            assertEquals( jObject3.opt("int"), -2462);
            jObject3 = new JSONObject("{\"int\" : -0X99e}");
            assertEquals( jObject3.opt("int"), -2462);

          } catch (Exception ex1) {
              ex = ex1;
View Full Code Here

            jObject3 = new JSONObject("{\"int\" : 0x7f}");
            assertEquals( jObject3.opt("int"), 127);
            jObject3 = new JSONObject("{\"int\" : -0x99e}");
            assertEquals( jObject3.opt("int"), -2462);
            jObject3 = new JSONObject("{\"int\" : -0X99e}");
            assertEquals( jObject3.opt("int"), -2462);

          } catch (Exception ex1) {
              ex = ex1;
              ex.printStackTrace();
          }
View Full Code Here

      Exception ex = null;
        // Test to make sure same exception is thrown when hex char is included in
        // normal identifier.
        try {
          JSONObject jObject3 = new JSONObject("{\"int\" : 343h}");
          assertEquals( jObject3.opt("int"), 127);


        } catch (Exception ex1) {
            ex = ex1;
        }
View Full Code Here

        Throwable cause = ex.getCause();
        assertTrue(cause == null);

        try {
            JSONObject jObject3 = new JSONObject("{\"int\" : 343a}");
            assertEquals( jObject3.opt("int"), 127);
          } catch (Exception ex1) {
              ex = ex1;
          }
          assertTrue(ex instanceof JSONException);
          cause = ex.getCause();
View Full Code Here

            obj.put("key2", "key2");
            obj.put("key3", "key3");
            String[] keys = {"key1", "key3"};
            JSONObject testObj = new JSONObject(obj, keys);
            assertTrue(testObj.size() == 2);
            assertTrue(testObj.opt("key2") == null);
            assertTrue(testObj.opt("key3").equals("key3"));
            assertTrue(testObj.opt("key1").equals("key1"));
        }
        catch (JSONException jex) {
            jex.printStackTrace();
View Full Code Here

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.