Package org.apache.pivot.json

Examples of org.apache.pivot.json.JSONSerializer.readObject()


    @Test
    public void testEquals() throws IOException, SerializationException {
        JSONSerializer jsonSerializer = new JSONSerializer();
        Object o1 = jsonSerializer.readObject(getClass().getResourceAsStream("sample.json"));
        Object o2 = jsonSerializer.readObject(getClass().getResourceAsStream("sample.json"));

        assertTrue(o1.equals(o2));

        List<?> d = JSON.getList(o1, "d");
        d.remove(0, 1);
View Full Code Here


public class BindTest {
    @Test
    public void testBind() throws IOException, SerializationException {
        JSONSerializer objectSerializer = new JSONSerializer();
        Object sampleObject = objectSerializer.readObject(getClass().getResourceAsStream("sample.json"));

        JSONSerializer beanSerializer = new JSONSerializer(SampleBean.class);
        SampleBean sampleBean = (SampleBean)beanSerializer.readObject(getClass().getResourceAsStream("sample.json"));

        assertEquals(sampleBean.getA(), JSON.get(sampleObject, "a"));
View Full Code Here

    public void testBind() throws IOException, SerializationException {
        JSONSerializer objectSerializer = new JSONSerializer();
        Object sampleObject = objectSerializer.readObject(getClass().getResourceAsStream("sample.json"));

        JSONSerializer beanSerializer = new JSONSerializer(SampleBean.class);
        SampleBean sampleBean = (SampleBean)beanSerializer.readObject(getClass().getResourceAsStream("sample.json"));

        assertEquals(sampleBean.getA(), JSON.get(sampleObject, "a"));
        assertEquals(sampleBean.getB(), JSON.get(sampleObject, "b"));
        assertEquals(sampleBean.getC(), JSON.get(sampleObject, "c"));
        assertEquals(sampleBean.getD(), JSON.get(sampleObject, "d"));
View Full Code Here

    }

    @Test
    public void testCRUD() throws IOException, SerializationException, QueryException {
        JSONSerializer jsonSerializer = new JSONSerializer();
        Object contact = jsonSerializer.readObject(getClass().getResourceAsStream("contact.json"));

        // Create
        PostQuery postQuery = new PostQuery(hostname, port, "/pivot-demos/rest_demo", secure);
        postQuery.setValue(contact);
        URL location = postQuery.execute();
View Full Code Here

            && clipboardContent.containsText()) {
            String json = null;
            JSONSerializer jsonSerializer = new JSONSerializer();
            try {
                json = clipboardContent.getText();
                setValue(jsonSerializer.readObject(new StringReader(json)));
            } catch (Exception exception) {
                Prompt.prompt(exception.getMessage(), window);
            }

            window.setTitle(WINDOW_TITLE);
View Full Code Here

                JSONSerializer jsonSerializer = new JSONSerializer();
                FileInputStream fileInputStream = null;
                try {
                    try {
                        fileInputStream = new FileInputStream(file);
                        setValue(jsonSerializer.readObject(fileInputStream));
                    } finally {
                        if (fileInputStream != null) {
                            fileInputStream.close();
                        }
                    }
View Full Code Here

            public void buttonPressed(Button button) {
                JSONSerializer serializer = new JSONSerializer();
                InputStream inputStream = getClass().getResourceAsStream("contact.json");

                try {
                    form.load(serializer.readObject(inputStream));
                    sourceLabel.setText("JSON");
                } catch(Exception exception) {
                    System.err.println(exception);
                }
View Full Code Here

        }

        JSONSerializer jsonSerializer = new JSONSerializer();

        try {
            setTableData((List<?>)jsonSerializer.readObject(tableData.openStream()));
        } catch (SerializationException exception) {
            throw new IllegalArgumentException(exception);
        } catch (IOException exception) {
            throw new IllegalArgumentException(exception);
        }
View Full Code Here

        if (inputStream != null) {
            JSONSerializer serializer = new JSONSerializer(charset);

            try {
                resourceMap = (Map<String, Object>)serializer.readObject(inputStream);
            } finally {
                inputStream.close();
            }
        }
View Full Code Here

        try {
            InputStream inputStream = location.openStream();

            try {
                JSONSerializer serializer = new JSONSerializer();
                Map<String, ?> properties = (Map<String, ?>)serializer.readObject(inputStream);

                font = Font.decode((String)properties.get("font"));

                List<String> colorCodes = (List<String>)properties.get("colors");
                colors = new ArrayList<Color>(colorCodes.getLength() * 3);
 
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.