Package org.apache.pivot.json

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


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

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


        window.requestFocus();

        if (System.in.available() > 0) {
            JSONSerializer jsonSerializer = new JSONSerializer();
            try {
                setValue(jsonSerializer.readObject(System.in));
            } catch (Exception exception) {
                // No-op
            }
        }
    }
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

        }

        Object value;
        try {
            JSONSerializer jsonSerializer = new JSONSerializer();
            value = jsonSerializer.readObject(new FileInputStream(file));
        } catch (IOException exception) {
            throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
        } catch (SerializationException exception) {
            throw new QueryException(Query.Status.INTERNAL_SERVER_ERROR);
        }
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

                System.out.println("Read null");
            }
        };

        jsonSerializer.getJSONSerializerListeners().add(jsonSerializerListener);
        Object o1 = jsonSerializer.readObject(getClass().getResourceAsStream("map.json"));
        assertEquals(JSON.get(o1, "count"), 8);

        jsonSerializer.getJSONSerializerListeners().remove(jsonSerializerListener);
        Object o2 = jsonSerializer.readObject(getClass().getResourceAsStream("map.json"));
View Full Code Here

        jsonSerializer.getJSONSerializerListeners().add(jsonSerializerListener);
        Object o1 = jsonSerializer.readObject(getClass().getResourceAsStream("map.json"));
        assertEquals(JSON.get(o1, "count"), 8);

        jsonSerializer.getJSONSerializerListeners().remove(jsonSerializerListener);
        Object o2 = jsonSerializer.readObject(getClass().getResourceAsStream("map.json"));

        assertTrue(o1.equals(o2));

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

        }

        JSONSerializer jsonSerializer = new JSONSerializer();

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

     * @throws SerializationException
     */
    @Test
    public void testUntypedList() throws IOException, SerializationException {
        JSONSerializer listSerializer = new JSONSerializer(ArrayList.class);
        List<?> list = (List<?>)listSerializer.readObject(new StringReader("[1, 2, 3, 4, 5]"));
        assertEquals(list.get(0), 1);
    }

    /**
     * Tests returning a typed list using {@code org.apache.pivot.util.TypeLiteral}.
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.