Package cc.plural.jsonij

Examples of cc.plural.jsonij.JSON.toJSON()


        list.add("value2");
        list.add("value3");
       
        JSONMarshaler.ALWAYS_USE_INNER_PROPERTY = false;
        JSON json1 = JSONMarshaler.marshalObject(list);
        System.out.println(json1.toJSON());

        assertTrue(json1.equals(JSON.parse("[\"value1\",\"value2\",\"value3\"]")));
       
        JSONMarshaler.ALWAYS_USE_INNER_PROPERTY = true;
        JSON json2 = JSONMarshaler.marshalObject(list);
View Full Code Here


        assertTrue(json1.equals(JSON.parse("[\"value1\",\"value2\",\"value3\"]")));
       
        JSONMarshaler.ALWAYS_USE_INNER_PROPERTY = true;
        JSON json2 = JSONMarshaler.marshalObject(list);
        System.out.println(json2.toJSON());
       
        assertTrue(json2.equals(JSON.parse("{\"$innerArray\":[\"value1\",\"value2\",\"value3\"]}")));
    }
}
View Full Code Here

        System.out.println("testCreateJSONObject");
        JSON.Object<JSON.String, Value> object = new JSON.Object<JSON.String, Value>();
        object.put(new JSON.String("attribute1"), new JSON.Numeric(33));
        object.put(new JSON.String("attribute2"), new JSON.String("value"));
        JSON jsonInstance = new JSON(object);
        System.out.println(jsonInstance.toJSON());
    }

        @Test
    public void testCreateJSONArray() throws Exception {
        System.out.println("testCreateJSONArray");
View Full Code Here

        array.add(JSON.TRUE);
        array.add(JSON.FALSE);
        array.add(JSON.NULL);
        array.add(object);
        JSON jsonInstance = new JSON(array);
        System.out.println(jsonInstance.toJSON());
    }
}
View Full Code Here

        Object object = JSONMarshaler.marshalJSON(stream, NebulousConfig.class);

        JSON output = JSONMarshaler.marshalObject(object);

        System.out.println(output.toJSON());
    }

    public static class NebulousConfig {

        @JSONCollector(true)
View Full Code Here

    public void testSupportEmptyObject() throws ParserException, IOException {
        System.out.println("Support Empty Object");
        String testInput = "{}";
        String testSoultion = "{}";
        JSON json = JSON.parse(testInput);
        String testOutput = json.toJSON();
        System.out.println(String.format("\tInput: %s\r\n\tOutput: %s", testInput, testOutput));
        assertEquals(testOutput, testSoultion);
        testInput = "{   \t\t   }";
        json = JSON.parse(testInput);
        testOutput = json.toJSON();
View Full Code Here

        String testOutput = json.toJSON();
        System.out.println(String.format("\tInput: %s\r\n\tOutput: %s", testInput, testOutput));
        assertEquals(testOutput, testSoultion);
        testInput = "{   \t\t   }";
        json = JSON.parse(testInput);
        testOutput = json.toJSON();
        System.out.println(String.format("\tInput: %s\r\n\tOutput: %s", testInput, testOutput));
        assertEquals(testOutput, testSoultion);
    }

    @Test
View Full Code Here

    public void testSupportSimpleObjectFloatValue() throws ParserException, IOException {
        System.out.println("Support simple Object float value");
        String testInput = "{ \"PI\":3.141E-10}";
        String testSoultion = "{\"PI\":3.141E-10}";
        JSON json = JSON.parse(testInput);
        String testOutput = json.toJSON();
        System.out.println(String.format("\tInput: %s\r\n\tOutput: %s", testInput, testOutput));
        assertEquals(testSoultion, testOutput);
        testInput = "{  \t     \"PI\"   \t   :\t   \t3.141E-10       }";
        json = JSON.parse(testInput);
        testOutput = json.toJSON();
View Full Code Here

        String testOutput = json.toJSON();
        System.out.println(String.format("\tInput: %s\r\n\tOutput: %s", testInput, testOutput));
        assertEquals(testSoultion, testOutput);
        testInput = "{  \t     \"PI\"   \t   :\t   \t3.141E-10       }";
        json = JSON.parse(testInput);
        testOutput = json.toJSON();
        System.out.println(String.format("\tInput: %s\r\n\tOutput: %s", testInput, testOutput));
        assertEquals(testSoultion, testOutput);
    }

    @Test
View Full Code Here

    public void testSupportLowercaseFloatValue() throws ParserException, IOException {
        System.out.println("Support lowcase float value");
        String testInput = "{ \"PI\":3.141e-10}";
        String testSoultion = "{\"PI\":3.141E-10}";
        JSON json = JSON.parse(testInput);
        String testOutput = json.toJSON();
        System.out.println(String.format("\tInput: %s\r\n\tOutput: %s", testInput, testOutput));
        assertEquals(testSoultion, testOutput);
        testInput = "{  \t     \"PI\" :\t   \t3.141e-10    }";
        json = JSON.parse(testInput);
        testOutput = json.toJSON();
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.