Package cc.plural.jsonij.marshal

Examples of cc.plural.jsonij.marshal.JavaMarshaler


    public void testGenericArray() throws ParserException, IOException {
        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>("John Marsden", "Tomorrow When The War Began", QUALITY.GOOD));
        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

        mapObject.put("innerMap1", innerMap);
        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

        Owner owner = new Owner("The Other John Marsden");
        book.setOwner(owner);
        owner.setBook(book);

        System.out.println("0 nested levels");
        JavaMarshaler marshaler = new JavaMarshaler();
        Value output = marshaler.marshalObject(book);
        System.out.println(output.toJSON());

        output = marshaler.marshalObject(owner);
        System.out.println(output.toJSON());

        System.out.println("1 nested level");
        JSONMarshaler.setCycleLevels(1);
        marshaler = new JavaMarshaler();
        output = marshaler.marshalObject(book);
        System.out.println(output.toJSON());

        output = marshaler.marshalObject(owner);
        System.out.println(output.toJSON());

        System.out.println("2 nested levels");
        JSONMarshaler.setCycleLevels(2);
        marshaler = new JavaMarshaler();
        output = marshaler.marshalObject(book);
        System.out.println(output.toJSON());

        output = marshaler.marshalObject(owner);
        System.out.println(output.toJSON());
    }
View Full Code Here

TOP

Related Classes of cc.plural.jsonij.marshal.JavaMarshaler

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.