Package cc.plural.jsonij

Examples of cc.plural.jsonij.JSON


                + "           \"long_name\" : \"United States\",\n"
                + "           \"short_name\" : \"US\",\n"
                + "           \"types\" : [ \"country\", \"political\" ]\n"
                + "       }\n"
                + "]}\n";
        JSON json = JSON.parse(jsonString);
       
        String regex1 = "\"^.*administrative_area_level_2.*$\"";
        System.out.println("Regex1:" + regex1);
        Value[] values = JPath.parse("/address_components[?(regex(@.types," + regex1 + "))]").evaluateAll(json);
        System.out.println("\tResultSize:" + values.length);
View Full Code Here


        MapTypeNoProps<String, String> map1 = new MapTypeNoProps<String, String>();
        map1.put("key1", "value1");
        map1.put("key2", "value2");

        JSONMarshaler.ALWAYS_USE_INNER_PROPERTY = false;
        JSON json1 = JSONMarshaler.marshalObject(map1);
        JSON jsonExpected1 = JSON.parse("{\"key2\":\"value2\",\"key1\":\"value1\"}");
       
        System.out.println("Parsed:" + json1.toJSON());
        System.out.println("Expected:" + jsonExpected1.toJSON());
        assertTrue(json1.equals(jsonExpected1));

        JSONMarshaler.ALWAYS_USE_INNER_PROPERTY = true;
        JSON json2 = JSONMarshaler.marshalObject(map1);
       
        JSON jsonExpected2 = JSON.parse("{\"$innerObject\":{\"key2\":\"value2\",\"key1\":\"value1\"}}");
        System.out.println("Parsed:" + json2.toJSON());
        System.out.println("Expected:" + jsonExpected2.toJSON());
        assertTrue(json2.equals(jsonExpected2));
    }
View Full Code Here

        map1.put("key2", "value2");
        map1.setPrivateInt(55);
        map1.publicString = "rah";

        JSONMarshaler.ALWAYS_USE_INNER_PROPERTY = false;
        JSON json1 = JSONMarshaler.marshalObject(map1);
        System.out.println(json1.toJSON());

        assertTrue(json1.equals(JSON.parse("{\"$innerObject\":{\"key2\":\"value2\",\"key1\":\"value1\"},\"privateInt\":55,\"publicString\":\"rah\"}")));
       
        JSONMarshaler.ALWAYS_USE_INNER_PROPERTY = true;
        JSON json2 = JSONMarshaler.marshalObject(map1);
        System.out.println(json2.toJSON());
       
        assertTrue(json2.equals(JSON.parse("{\"$innerObject\":{\"key2\":\"value2\",\"key1\":\"value1\"},\"privateInt\":55,\"publicString\":\"rah\"}")));
    }
View Full Code Here

        list.add("value1");
        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);
        System.out.println(json2.toJSON());
       
        assertTrue(json2.equals(JSON.parse("{\"$innerArray\":[\"value1\",\"value2\",\"value3\"]}")));
    }
View Full Code Here

    public void testCreateJSONObject() throws Exception {
        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());
    }
View Full Code Here

        array.add(new JSON.String("value"));
        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

        URL url = getClass().getResource("/etc/config.json");
        InputStream stream = url.openStream();

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

        JSON output = JSONMarshaler.marshalObject(object);

        System.out.println(output.toJSON());
    }
View Full Code Here

    @Test
    public void testObjectMapProperty() throws ParserException, IOException {
        System.out.println("testObjectMapProperty");
       
        String jsonString = "{\"map\":{\"1\":\"One\",\"2\":\"Two\"}}";
        JSON json = JSON.parse(jsonString);
       
        //ObjectWithMapObjectObject map = (ObjectWithMapObjectObject) JSONMarshaler.marshalJSON(json, ObjectWithMapObjectObject.class);
       
        //assertEquals(map.getMap().size(), 2);
    }
View Full Code Here

    @Test
    public void testMarshalJSONStringIntoIntArray() throws JSONMarshalerException, IOException, ParserException {
        System.out.println("marshal JSON into Array");
        String inputJSONDocument = "[1,2,3,4,5]";
        JSON inputJSON = JSON.parse(inputJSONDocument);
        Object marshal = JSONMarshaler.marshalJSON(inputJSON, int[].class);
        JSON outputJSON = JSONMarshaler.marshalObject(marshal);
        System.out.println(String.format("InputJSON: %s", inputJSON));
        System.out.println(String.format("MarshaledObjectToString: %s", marshal));
        System.out.println(String.format("OutputJSON: %s", outputJSON));
        assertNotNull(marshal);
        assertEquals(inputJSON, outputJSON);
View Full Code Here

    @Test
    public void testMarshalJSONStringIntoObject() throws JSONMarshalerException, IOException, ParserException {
        System.out.println("marshal JSON into Object");
        String inputJSONDocument = "{\"message\":\"Hello JSON!\", \"rah\":-69, \"id\": 585757346726,    \"flag\": true, \"innerDoubleArray\": [1], \"inner\": {\"someValue\": \"hmmmn...\", \"rah\": [5,4,3,2,1]}}";

        JSON inputJSON = JSON.parse(inputJSONDocument);
        Object marshal = JSONMarshaler.marshalJSON(inputJSON, JSONObject.class);
        JSON outputJSON = JSONMarshaler.marshalObject(marshal);
        System.out.println(String.format("InputJSON: %s", inputJSON));
        System.out.println(String.format("MarshaledObjectToString: %s", marshal));
        System.out.println(String.format("OutputJSON: %s", outputJSON));

        assertNotNull(marshal);
View Full Code Here

TOP

Related Classes of cc.plural.jsonij.JSON

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.