Package cc.plural.jsonij

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


    public void testMarshalJSONNumericBigInteger() throws JSONMarshalerException, IOException, ParserException {
        System.out.println("testMarshalJSONNumericBigInteger");

        String inputJSONDocument = "12345678900987654321123456789009876543211234567890098765432112345678900987654321";       
        Value inputValue = JSON.parseValue(inputJSONDocument);
        System.out.println(String.format("InputJSON: %s", inputValue.toJSON()));
        Object marshal = JSONMarshaler.marshalJSON(inputValue, BigInteger.class);
        System.out.println(String.format("MarshaledObjectToString: %s", marshal));
        Value outputValue = JSONMarshaler.marshalObjectToValue(marshal);
        System.out.println(String.format("OutputJSON: %s", outputValue));
View Full Code Here


    public void testMarshalJSONNumericBigDecimal() throws JSONMarshalerException, IOException, ParserException {
        System.out.println("testMarshalJSONNumericBigDecimal");

        String inputJSONDocument = "12345678900987654321123456789009876543211234567890098765432112345678900987654321.12345678900987654321123456789009876543211234567890098765432112345678900987654321123456789009";       
        Value inputValue = JSON.parseValue(inputJSONDocument);
        System.out.println(String.format("InputJSON: %s", inputValue.toJSON()));
        Object marshal = JSONMarshaler.marshalJSON(inputValue, BigDecimal.class);
        System.out.println(String.format("MarshaledObjectToString: %s", marshal));
        Value outputValue = JSONMarshaler.marshalObjectToValue(marshal);
        System.out.println(String.format("OutputJSON: %s", outputValue));
View Full Code Here

        JPathParser jPathParser = new JPathParser();
        JPath<?> path1 = jPathParser.parse("/store");
        path1.setRecordEvaluateTime(true);
        Value value = path1.evaluate(json);
        System.out.println(value.getValueType() + "(" + value.nestedSize() + "): " + value.toJSON() + " (in " + path1.getLastEvaluateTime() + " ms)");

        JPath<?> path2 = jPathParser.parse("/store/book[-2]");
        path2.setRecordEvaluateTime(true);
        value = path2.evaluate(json);
        System.out.println(value.getValueType() + "--> (" + value.nestedSize() + "): " + value.toJSON() + " (in " + path2.getLastEvaluateTime() + " ms)");
View Full Code Here

        System.out.println(value.getValueType() + "(" + value.nestedSize() + "): " + value.toJSON() + " (in " + path1.getLastEvaluateTime() + " ms)");

        JPath<?> path2 = jPathParser.parse("/store/book[-2]");
        path2.setRecordEvaluateTime(true);
        value = path2.evaluate(json);
        System.out.println(value.getValueType() + "--> (" + value.nestedSize() + "): " + value.toJSON() + " (in " + path2.getLastEvaluateTime() + " ms)");

        JPath<?> path3 = jPathParser.parse("/store/book[2]/title");
        path3.setRecordEvaluateTime(true);
        value = path3.evaluate(json);
        System.out.println(value.getValueType() + "(" + value.nestedSize() + "): " + value.toJSON() + " (in " + path3.getLastEvaluateTime() + " ms)");
View Full Code Here

        System.out.println(value.getValueType() + "--> (" + value.nestedSize() + "): " + value.toJSON() + " (in " + path2.getLastEvaluateTime() + " ms)");

        JPath<?> path3 = jPathParser.parse("/store/book[2]/title");
        path3.setRecordEvaluateTime(true);
        value = path3.evaluate(json);
        System.out.println(value.getValueType() + "(" + value.nestedSize() + "): " + value.toJSON() + " (in " + path3.getLastEvaluateTime() + " ms)");

        JPath<?> path4 = jPathParser.parse("/store/book[$]/title");
        path4.setRecordEvaluateTime(true);
        value = path4.evaluate(json);
        System.out.println(value.getValueType() + "(" + value.nestedSize() + "): " + value.toJSON() + " (in " + path4.getLastEvaluateTime() + " ms)");
View Full Code Here

        System.out.println(value.getValueType() + "(" + value.nestedSize() + "): " + value.toJSON() + " (in " + path3.getLastEvaluateTime() + " ms)");

        JPath<?> path4 = jPathParser.parse("/store/book[$]/title");
        path4.setRecordEvaluateTime(true);
        value = path4.evaluate(json);
        System.out.println(value.getValueType() + "(" + value.nestedSize() + "): " + value.toJSON() + " (in " + path4.getLastEvaluateTime() + " ms)");

        JPath<?> path5 = jPathParser.parse("/store/book[last()-3]/title");
        path5.setRecordEvaluateTime(true);
        value = path5.evaluate(json);
        System.out.println(value.getValueType() + "(" + value.nestedSize() + "): " + value.toJSON() + " (in " + path5.getLastEvaluateTime() + " ms)");
View Full Code Here

        System.out.println(value.getValueType() + "(" + value.nestedSize() + "): " + value.toJSON() + " (in " + path4.getLastEvaluateTime() + " ms)");

        JPath<?> path5 = jPathParser.parse("/store/book[last()-3]/title");
        path5.setRecordEvaluateTime(true);
        value = path5.evaluate(json);
        System.out.println(value.getValueType() + "(" + value.nestedSize() + "): " + value.toJSON() + " (in " + path5.getLastEvaluateTime() + " ms)");

        JPath<?> path6 = jPathParser.parse("/store/book[last()-1337]/title");
        try {
            value = path6.evaluate(json);
        }
View Full Code Here

        }

        JPath<?> path7 = JPath.parse("/store/number[$-1337]");
        path7.setRecordEvaluateTime(true);
        value = path7.evaluate(json);
        System.out.println(value.getValueType() + "(" + value.nestedSize() + "): " + value.toJSON() + " (in " + path7.getLastEvaluateTime() + " ms)");

    }

    @Test
    public void testExpression0() throws IOException, ParserException {
View Full Code Here

        JPathParser jPathParser = new JPathParser();
        JPath<?> path1 = jPathParser.parse("/store");
        path1.setRecordEvaluateTime(true);
        Value value1 = path1.evaluate(json);
        System.out.println(value1.getValueType() + "(" + value1.nestedSize() + "): " + value1.toJSON() + " (in " + path1.getLastEvaluateTime() + " ms)");

        JPath<?> path2 = jPathParser.parse("/store/book[?(@.title=\"Sword of Honour\")]/author");
        path2.setRecordEvaluateTime(true);
        Value value2 = path2.evaluate(json);
        System.out.println(value2.getValueType() + "(" + value2.nestedSize() + "): " + value2.toJSON() + " (in " + path2.getLastEvaluateTime() + " ms)");
View Full Code Here

        System.out.println(value1.getValueType() + "(" + value1.nestedSize() + "): " + value1.toJSON() + " (in " + path1.getLastEvaluateTime() + " ms)");

        JPath<?> path2 = jPathParser.parse("/store/book[?(@.title=\"Sword of Honour\")]/author");
        path2.setRecordEvaluateTime(true);
        Value value2 = path2.evaluate(json);
        System.out.println(value2.getValueType() + "(" + value2.nestedSize() + "): " + value2.toJSON() + " (in " + path2.getLastEvaluateTime() + " ms)");

        JPath<?> path3 = jPathParser.parse("/book[?(@.author=\"J. R. R. Tolkien\")]/title");
        path3.setRecordEvaluateTime(true);
        Value value3 = path3.evaluate(value1);
        System.out.println(value3.getValueType() + "(" + value3.nestedSize() + "): " + value3.toJSON() + " (in " + path3.getLastEvaluateTime() + " ms)");
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.