Package org.apache.wink.json4j

Examples of org.apache.wink.json4j.JSONWriter


    /**
     * Test the contructor.
     */
    public void test_new() {
        StringWriter w = new StringWriter();
        JSONWriter jWriter = new JSONWriter(w);
    }
View Full Code Here


     */
    public void test_WriteEmptyObject() {
        Exception ex = null;
        try{
            StringWriter w = new StringWriter();
            JSONWriter jWriter = new JSONWriter(w);
            jWriter.object();
            jWriter.endObject();
            String str = w.toString();
            // Verify it parses.
            JSONObject test = new JSONObject(str);
            assertTrue(str.equals("{}"));
        }catch(Exception ex1){
View Full Code Here

     */
    public void test_WriteEmptyObjectClose() {
        Exception ex = null;
        try{
            StringWriter w = new StringWriter();
            JSONWriter jWriter = new JSONWriter(w);
            jWriter.object();
            jWriter.close();
            String str = w.toString();
            // Verify it parses.
            JSONObject test = new JSONObject(str);
            assertTrue(str.equals("{}"));
        }catch(Exception ex1){
View Full Code Here

     */
    public void test_WriteEmptyArray() {
        Exception ex = null;
        try{
            StringWriter w = new StringWriter();
            JSONWriter jWriter = new JSONWriter(w);
            jWriter.array();
            jWriter.endArray();
            String str = w.toString();
            // Verify it parses.
            JSONArray test = new JSONArray(str);
            assertTrue(str.equals("[]"));
        }catch(Exception ex1){
View Full Code Here

     */
    public void test_WriteEmptyArrayClose() {
        Exception ex = null;
        try{
            StringWriter w = new StringWriter();
            JSONWriter jWriter = new JSONWriter(w);
            jWriter.array();
            jWriter.close();

            String str = w.toString();
            // Verify it parses.
            JSONArray test = new JSONArray(str);
            assertTrue(str.equals("[]"));
View Full Code Here

     */
    public void test_WriteObjectAttrString() {
        Exception ex = null;
        try{
            StringWriter w = new StringWriter();
            JSONWriter jWriter = new JSONWriter(w);
            jWriter.object();
            jWriter.key("foo");
            jWriter.value("bar");
            jWriter.close();
            String str = w.toString();
            // Verify it parses.
            JSONObject test = new JSONObject(str);
            assertTrue(str.equals("{\"foo\":\"bar\"}"));
        }catch(Exception ex1){
View Full Code Here

     */
    public void test_WriteObjectAttrInt() {
        Exception ex = null;
        try{
            StringWriter w = new StringWriter();
            JSONWriter jWriter = new JSONWriter(w);
            jWriter.object();
            jWriter.key("foo");
            jWriter.value(1);
            jWriter.close();
            String str = w.toString();
            // Verify it parses.
            JSONObject test = new JSONObject(str);
            assertTrue(str.equals("{\"foo\":1}"));
        }catch(Exception ex1){
View Full Code Here

     */
    public void test_WriteObjectAttrLong() {
        Exception ex = null;
        try{
            StringWriter w = new StringWriter();
            JSONWriter jWriter = new JSONWriter(w);
            jWriter.object();
            jWriter.key("foo");
            jWriter.value((long)1);
            jWriter.close();
            String str = w.toString();
            // Verify it parses.
            JSONObject test = new JSONObject(str);
            assertTrue(str.equals("{\"foo\":1}"));
        }catch(Exception ex1){
View Full Code Here

     */
    public void test_WriteObjectAttrShort() {
        Exception ex = null;
        try{
            StringWriter w = new StringWriter();
            JSONWriter jWriter = new JSONWriter(w);
            jWriter.object();
            jWriter.key("foo");
            jWriter.value((short)1);
            jWriter.close();
            String str = w.toString();
            // Verify it parses.
            JSONObject test = new JSONObject(str);
            assertTrue(str.equals("{\"foo\":1}"));
        }catch(Exception ex1){
View Full Code Here

     */
    public void test_WriteObjectAttrDouble() {
        Exception ex = null;
        try{
            StringWriter w = new StringWriter();
            JSONWriter jWriter = new JSONWriter(w);
            jWriter.object();
            jWriter.key("foo");
            jWriter.value((double)100.959);
            jWriter.close();
            String str = w.toString();
            // Verify it parses.
            JSONObject test = new JSONObject(str);
            assertTrue(str.equals("{\"foo\":100.959}"));
        }catch(Exception ex1){
View Full Code Here

TOP

Related Classes of org.apache.wink.json4j.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.