Package org.slim3.repackaged.org.json

Examples of org.slim3.repackaged.org.json.JSONObject.optString()


    @Override
    public String readProperty(String name){
        JSONObject o = object.optJSONObject(this.name);
        if(o == null) return null;
        return o.optString(name, null);
    }

    private JSONObject object;
    private String name;
}
View Full Code Here


    @Override
    public String readProperty(String name){
        if(array == null) return null;
        JSONObject o = array.optJSONObject(index);
        if(o == null) return null;
        return o.optString(name, null);
    }

    /**
     * Create the new JSONRootReader on the current index.
     *
 
View Full Code Here

    @Test
    public void optInt() throws Exception {
        JSONObject j = new JSONObject("{str: \"hello\", int: 3}");
        Assert.assertEquals(0, j.optInt("v"));
        Assert.assertEquals(0, j.optInt("str"));
        Assert.assertEquals("hello", j.optString("str"));
        Assert.assertEquals("3", j.optString("int"));
    }

    @Test
    public void wrapperIntValueTest() throws Exception {
View Full Code Here

    public void optInt() throws Exception {
        JSONObject j = new JSONObject("{str: \"hello\", int: 3}");
        Assert.assertEquals(0, j.optInt("v"));
        Assert.assertEquals(0, j.optInt("str"));
        Assert.assertEquals("hello", j.optString("str"));
        Assert.assertEquals("3", j.optString("int"));
    }

    @Test
    public void wrapperIntValueTest() throws Exception {
        JSONObject j = new JSONObject("{value: 1}");
View Full Code Here

        JSONObject j =
            new JSONObject(
                "{"
                    + "\"user1\":{\"authDomain\":\"authDomain\",\"email\":\"user@test.com\"}"
                    + "}");
        Assert.assertEquals("", j.optString("name"));
        Assert.assertNull(j.optString("name", null));
        JSONObject u = j.getJSONObject("user1");
        String domain = u.optString("authDomain", null);
        String email = u.optString("email", null);
        String uid = u.optString("userid", null);
View Full Code Here

            new JSONObject(
                "{"
                    + "\"user1\":{\"authDomain\":\"authDomain\",\"email\":\"user@test.com\"}"
                    + "}");
        Assert.assertEquals("", j.optString("name"));
        Assert.assertNull(j.optString("name", null));
        JSONObject u = j.getJSONObject("user1");
        String domain = u.optString("authDomain", null);
        String email = u.optString("email", null);
        String uid = u.optString("userid", null);
        String fid = u.optString("federatedIdentity");
View Full Code Here

                    + "\"user1\":{\"authDomain\":\"authDomain\",\"email\":\"user@test.com\"}"
                    + "}");
        Assert.assertEquals("", j.optString("name"));
        Assert.assertNull(j.optString("name", null));
        JSONObject u = j.getJSONObject("user1");
        String domain = u.optString("authDomain", null);
        String email = u.optString("email", null);
        String uid = u.optString("userid", null);
        String fid = u.optString("federatedIdentity");
        if (domain != null && email != null) {
            if (uid == null) {
View Full Code Here

                    + "}");
        Assert.assertEquals("", j.optString("name"));
        Assert.assertNull(j.optString("name", null));
        JSONObject u = j.getJSONObject("user1");
        String domain = u.optString("authDomain", null);
        String email = u.optString("email", null);
        String uid = u.optString("userid", null);
        String fid = u.optString("federatedIdentity");
        if (domain != null && email != null) {
            if (uid == null) {
                new User(email, domain);
View Full Code Here

        Assert.assertEquals("", j.optString("name"));
        Assert.assertNull(j.optString("name", null));
        JSONObject u = j.getJSONObject("user1");
        String domain = u.optString("authDomain", null);
        String email = u.optString("email", null);
        String uid = u.optString("userid", null);
        String fid = u.optString("federatedIdentity");
        if (domain != null && email != null) {
            if (uid == null) {
                new User(email, domain);
            } else if (fid == null) {
View Full Code Here

        Assert.assertNull(j.optString("name", null));
        JSONObject u = j.getJSONObject("user1");
        String domain = u.optString("authDomain", null);
        String email = u.optString("email", null);
        String uid = u.optString("userid", null);
        String fid = u.optString("federatedIdentity");
        if (domain != null && email != null) {
            if (uid == null) {
                new User(email, domain);
            } else if (fid == null) {
                new User(email, domain, uid);
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.