Package cc.plural.jsonij

Examples of cc.plural.jsonij.Value


    }

    @SuppressWarnings({"unchecked", "rawtypes"})
    static Media readMedia(JSON.Object mediaJsonObject) {
        Media media = new Media();
        Value bitrate = mediaJsonObject.get("bitrate");
        if (bitrate != null && !bitrate.isNull()) {
            media.bitrate = bitrate.getInt();
            media.hasBitrate = true;
        }
        Value copyright = mediaJsonObject.get("copyright");
        if (copyright != null && !copyright.isNull()) {
            media.copyright = copyright.getString();
        }
        media.duration = mediaJsonObject.get("duration").getLong();
        media.format = mediaJsonObject.get("format").getString();
        media.height = mediaJsonObject.get("height").getInt();
        JSON.Array<Value> personValues = (JSON.Array<Value>) mediaJsonObject.get("persons");
View Full Code Here


        System.out.println("testGenericArray");
        MyArray<Book<String>> bookList = new MyArray<Book<String>>();
        bookList.add(new RatedBook<String>("John Marsden", "Tomorrow When The War Began", "ISBN-0192-2928", QUALITY.GOOD));
        bookList.add(new RatedBook<String>("David Johnsonbaugh", "Discrete Mathematics", "ISBN-0192-2928", QUALITY.BAD));
        JavaMarshaler marshaler = new JavaMarshaler();
        Value output = marshaler.marshalObject(bookList);
        Value expected = JSON.parse("{\"$innerArray\":[{\"$innerArray\":[{\"$innerArray\":[],\"author\":\"John Marsden\",\"title\":\"Tomorrow When The War Began\",\"test\":-99,\"quality\":\"GOOD\"},{\"$innerArray\":[],\"author\":\"David Johnsonbaugh\",\"title\":\"Discrete Mathematics\",\"test\":-99,\"quality\":\"BAD\"},{\"$innerArray\":[\"A String\"],\"author\":\"R.A.Salvatore\",\"title\":\"Homeland\",\"iSBN\":\"ISBN-0192-2928\",\"test\":-99,\"quality\":\"GOOD\"}],\"value\":100}],\"someValue\":\"this is a string\"}\n").getRoot();
        System.out.println(output.toJSON());
        //assertEquals(output, expected);
    }
View Full Code Here

        bookList.add(new RatedBook<String>("David Johnsonbaugh", "Discrete Mathematics", QUALITY.BAD));
        bookList.add(book);
        bookBookList.add(bookList);

        JavaMarshaler marshaler = new JavaMarshaler();
        Value output = marshaler.marshalObject(bookBookList);
        System.out.println(output.toJSON());
    }
View Full Code Here

        innerMap = new MyMap2<java.lang.String, Integer>();
        innerMap.put("blah", 69);
        mapObject.put("innerMap2", innerMap);

        JavaMarshaler marshaler = new JavaMarshaler();
        Value output = marshaler.marshalObject(mapObject);
        System.out.println(output.toJSON());
    }
View Full Code Here

        System.out.println("testCodecStoreRegisterDate");

        assertFalse(JSONMarshaler.hasCodec(Date.class));

        Date testDate = new Date();
        Value valueNoCodec = JSONMarshaler.marshalObjectToValue(testDate);

        System.out.println("Value No Codec:" + valueNoCodec);

        assertFalse(JSONMarshaler.hasCodec(Date.class));

        JSONMarshaler.registerCodec(Date.class, DateJSONValueCodec.class);

        assertTrue(JSONMarshaler.hasCodec(Date.class));

        Value valueCodec = JSONMarshaler.marshalObjectToValue(testDate);

        System.out.println("Value Codec:" + valueCodec);

///        assertEquals(valueCodec.toString(), "{\"time\":" + testDate.getTime() + "}");
    }
View Full Code Here

        System.out.println("testCodecStoreRegisterDateEncodeDecode");

        assertFalse(JSONMarshaler.hasCodec(Date.class));

        InternalDate testDate = new InternalDate();
        Value valueNoCodec = JSONMarshaler.marshalObjectToValue(testDate);

        System.out.println("Value No Codec:" + valueNoCodec);

        assertFalse(JSONMarshaler.hasCodec(InternalDate.class));

        JSONMarshaler.registerCodec(InternalDate.class, DateJSONValueCodec.class);

        assertTrue(JSONMarshaler.hasCodec(InternalDate.class));

        Value valueCodec = JSONMarshaler.marshalObjectToValue(testDate);

        System.out.println("Value Codec:" + valueCodec);

        InternalDate decodeDate = DateJSONValueCodec.decode(valueCodec, InternalDate.class);
       
View Full Code Here

        InternalDate encodeDate = new InternalDate();

        System.out.println("EncodeDate:" + encodeDate);

        Value value = DateJSONValueCodec.encode(encodeDate);

        InternalDate decodeDate = DateJSONValueCodec.decode(value, InternalDate.class);

        System.out.println("DecodeDate:" + decodeDate);
View Full Code Here

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

        String inputJSONDocument = "1";       
        Value inputValue = JSON.parseValue(inputJSONDocument);
        System.out.println(String.format("InputJSON: %s", inputValue.toJSON()));
        Object marshal = JSONMarshaler.marshalJSON(inputValue, byte.class);
        System.out.println(String.format("MarshaledObjectToString: %s", marshal));
        Value outputValue = JSONMarshaler.marshalObjectToValue(marshal);
        System.out.println(String.format("OutputJSON: %s", outputValue));

        assertNotNull(marshal);
        assertEquals(inputValue, outputValue);
    }
View Full Code Here

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

        String inputJSONDocument = "-33333";       
        Value inputValue = JSON.parseValue(inputJSONDocument);
        System.out.println(String.format("InputJSON: %s", inputValue.toJSON()));
        Object marshal = JSONMarshaler.marshalJSON(inputValue, Float.class);
        System.out.println(String.format("MarshaledObjectToString: %s", marshal));
        Value outputValue = JSONMarshaler.marshalObjectToValue(marshal);
        System.out.println(String.format("OutputJSON: %s", outputValue));

        assertNotNull(marshal);
        assertEquals(inputValue, outputValue);
    }
View Full Code Here

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

        String inputJSONDocument = "1337";       
        Value inputValue = JSON.parseValue(inputJSONDocument);
        System.out.println(String.format("InputJSON: %s", inputValue.toJSON()));
        Object marshal = JSONMarshaler.marshalJSON(inputValue, int.class);
        System.out.println(String.format("MarshaledObjectToString: %s", marshal));
        Value outputValue = JSONMarshaler.marshalObjectToValue(marshal);
        System.out.println(String.format("OutputJSON: %s", outputValue));

        assertNotNull(marshal);
        assertEquals(inputValue, outputValue);
    }
View Full Code Here

TOP

Related Classes of cc.plural.jsonij.Value

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.