Package org.apache.wink.json4j.compat

Examples of org.apache.wink.json4j.compat.JSONObject


        Exception ex = null;
        try {
            Reader reader = new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("utf8_helloworld_ko.json"), "UTF-8");
            System.setProperty("org.apache.wink.common.model.json.factory.impl", "org.apache.wink.json4j.compat.impl.ApacheJSONFactory");
            JSONFactory factory = JSONFactory.newInstance();
            JSONObject jObject = factory.createJSONObject(reader);
            reader.close();
            assertTrue(jObject.getString("greet").equals("\uc548\ub155 \uc138\uc0c1\uc544"));
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
        assertTrue(ex == null);
View Full Code Here


        Exception ex = null;
        try {
            Reader reader = new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("utf8_lowerchar.json"), "UTF-8");
            System.setProperty("org.apache.wink.common.model.json.factory.impl", "org.apache.wink.json4j.compat.impl.ApacheJSONFactory");
            JSONFactory factory = JSONFactory.newInstance();
            JSONObject jObject = factory.createJSONObject(reader);
            reader.close();
            assertTrue(jObject.getString("message").equals("\u00c5\u00c5\u00c5\u00c5"));
            assertTrue(jObject.toString().equals("{\"message\":\"\\u00c5\\u00c5\\u00c5\\u00c5\"}"));
        } catch (Exception ex1) {
            ex = ex1;
            ex.printStackTrace();
        }
        assertTrue(ex == null);
View Full Code Here

            JSONWriter jWriter = factory.createJSONWriter(w);
            jWriter.object();
            jWriter.endObject();
            String str = w.toString();
            // Verify it parses.
            JSONObject test = factory.createJSONObject(str);
            assertTrue(str.equals("{}"));
        }catch(Exception ex1){
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

            JSONWriter jWriter = factory.createJSONWriter(w);
            jWriter.object();
            jWriter.close();
            String str = w.toString();
            // Verify it parses.
            JSONObject test = factory.createJSONObject(str);
            assertTrue(str.equals("{}"));
        }catch(Exception ex1){
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

            jWriter.key("foo");
            jWriter.value("bar");
            jWriter.close();
            String str = w.toString();
            // Verify it parses.
            JSONObject test = factory.createJSONObject(str);
            assertTrue(str.equals("{\"foo\":\"bar\"}"));
        }catch(Exception ex1){
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

            jWriter.key("foo");
            jWriter.value(1);
            jWriter.close();
            String str = w.toString();
            // Verify it parses.
            JSONObject test = factory.createJSONObject(str);
            assertTrue(str.equals("{\"foo\":1}"));
        }catch(Exception ex1){
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

            jWriter.key("foo");
            jWriter.value((long)1);
            jWriter.close();
            String str = w.toString();
            // Verify it parses.
            JSONObject test = factory.createJSONObject(str);
            assertTrue(str.equals("{\"foo\":1}"));
        }catch(Exception ex1){
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

            jWriter.key("foo");
            jWriter.value((short)1);
            jWriter.close();
            String str = w.toString();
            // Verify it parses.
            JSONObject test = factory.createJSONObject(str);
            assertTrue(str.equals("{\"foo\":1}"));
        }catch(Exception ex1){
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

            jWriter.key("foo");
            jWriter.value((double)100.959);
            jWriter.close();
            String str = w.toString();
            // Verify it parses.
            JSONObject test = factory.createJSONObject(str);
            assertTrue(str.equals("{\"foo\":100.959}"));
        }catch(Exception ex1){
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

            jWriter.key("foo");
            jWriter.value(true);
            jWriter.close();
            String str = w.toString();
            // Verify it parses.
            JSONObject test = factory.createJSONObject(str);
            assertTrue(str.equals("{\"foo\":true}"));
        }catch(Exception ex1){
            ex = ex1;
            ex.printStackTrace();
        }
View Full Code Here

TOP

Related Classes of org.apache.wink.json4j.compat.JSONObject

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.