Package org.ofbiz.base.json

Examples of org.ofbiz.base.json.JSONWriter


            writer.write(str);
            return true;
        } else {
            StringWriter sw = new StringWriter();
            IndentingWriter indenting = new IndentingWriter(writer, true, false);
            JSONWriter jsonWriter;
            if (allowJsonResolve) {
                jsonWriter = new JSONWriter(indenting, JSONWriter.ResolvingFallbackHandler);
            } else {
                jsonWriter = new JSONWriter(indenting);
            }
            jsonWriter.write(value);
            writer.write(sw.toString());
            return true;
        }
    }
View Full Code Here


        return new JSON(new StringReader(value)).allowResolve(allowResolve).JSONValue();
    }

    protected String getJSON(Object object, boolean allowResolve) throws Exception {
        StringWriter writer = new StringWriter();
        JSONWriter jsonWriter;
        if (allowResolve) {
            jsonWriter = new JSONWriter(writer, JSONWriter.ResolvingFallbackHandler);
        } else {
            jsonWriter = new JSONWriter(writer);
        }
        assertTrue("writer is IndentingWriter", jsonWriter.getWriter() instanceof IndentingWriter);
        jsonWriter.write(object);
        return writer.toString();
    }
View Full Code Here

        assertEquals("write " + type, json, getJSON(obj, true));
        assertEquals("parse " + type, obj, parseJSON(json, true));
    }

    public void testClose() throws Exception {
        JSONWriter writer = new JSONWriter(new OutputStreamWriter(new ByteArrayOutputStream()));
        writer.close();
        IOException caught = null;
        try {
            writer.write("");
        } catch (IOException e) {
            caught = e;
        } finally {
            assertNotNull("write after close", caught);
        }
View Full Code Here

            writer.write(str);
            return true;
        } else {
            StringWriter sw = new StringWriter();
            IndentingWriter indenting = new IndentingWriter(writer, true, false);
            JSONWriter jsonWriter;
            if (allowJsonResolve) {
                jsonWriter = new JSONWriter(indenting, JSONWriter.ResolvingFallbackHandler);
            } else {
                jsonWriter = new JSONWriter(indenting);
            }
            jsonWriter.write(value);
            writer.write(sw.toString());
            return true;
        }
    }
View Full Code Here

            writer.write(str);
            return true;
        } else {
            StringWriter sw = new StringWriter();
            IndentingWriter indenting = new IndentingWriter(writer, true, false);
            JSONWriter jsonWriter;
            if (allowJsonResolve) {
                jsonWriter = new JSONWriter(indenting, JSONWriter.ResolvingFallbackHandler);
            } else {
                jsonWriter = new JSONWriter(indenting);
            };
            jsonWriter.write(value);
            writer.write(sw.toString());
            return true;
        }
    }
View Full Code Here

            writer.write(str);
            return true;
        } else {
            StringWriter sw = new StringWriter();
            IndentingWriter indenting = new IndentingWriter(writer, true, false);
            JSONWriter jsonWriter;
            if (allowJsonResolve) {
                jsonWriter = new JSONWriter(indenting, JSONWriter.ResolvingFallbackHandler);
            } else {
                jsonWriter = new JSONWriter(indenting);
            };
            jsonWriter.write(value);
            writer.write(sw.toString());
            return true;
        }
    }
View Full Code Here

        return new JSON(new StringReader(value)).allowResolve(allowResolve).JSONValue();
    }

    protected String getJSON(Object object, boolean allowResolve) throws Exception {
        StringWriter writer = new StringWriter();
        JSONWriter jsonWriter;
        if (allowResolve) {
            jsonWriter = new JSONWriter(writer, JSONWriter.ResolvingFallbackHandler);
        } else {
            jsonWriter = new JSONWriter(writer);
        };
        assertTrue("writer is IndentingWriter", jsonWriter.getWriter() instanceof IndentingWriter);
        jsonWriter.write(object);
        return writer.toString();
    }
View Full Code Here

        assertEquals("write " + type, json, getJSON(obj, true));
        assertEquals("parse " + type, obj, parseJSON(json, true));
    }

    public void testClose() throws Exception {
        JSONWriter writer = new JSONWriter(new OutputStreamWriter(new ByteArrayOutputStream()));
        writer.close();
        IOException caught = null;
        try {
            writer.write("");
        } catch (IOException e) {
            caught = e;
        } finally {
            assertNotNull("write after close", caught);
        }
View Full Code Here

TOP

Related Classes of org.ofbiz.base.json.JSONWriter

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.