Package net.sf.json

Examples of net.sf.json.JSONObject


        mockJSON.expectedMessageCount(1);
        mockJSON.message(0).body().isInstanceOf(byte[].class);

        Object json = template.requestBody("direct:marshalInlineOptions", in);
        String jsonString = context.getTypeConverter().convertTo(String.class, json);
        JSONObject obj = (JSONObject) JSONSerializer.toJSON(jsonString);
        assertEquals("JSON must contain 1 top-level element", 1, obj.entrySet().size());
        assertTrue("Top-level element must be named root", obj.has("root"));
        // check that no child of the top-level element has a colon in its key,
        // which would denote that
        // a namespace prefix exists
        for (Object key : obj.getJSONObject("root").keySet()) {
            assertFalse("A key contains a colon", ((String) key).contains(":"));
        }

        mockJSON.assertIsSatisfied();
    }
View Full Code Here


        mockXML.expectedMessageCount(1);
        mockXML.message(0).body().isInstanceOf(String.class);

        Object json = template.requestBody("direct:marshal", in);
        String jsonString = context.getTypeConverter().convertTo(String.class, json);
        JSONObject obj = (JSONObject) JSONSerializer.toJSON(jsonString);
        assertEquals("JSONObject doesn't contain 7 keys", 7, obj.entrySet().size());

        template.sendBody("direct:unmarshal", jsonString);

        mockJSON.assertIsSatisfied();
        mockXML.assertIsSatisfied();
View Full Code Here

        mockJSON.expectedMessageCount(1);
        mockJSON.message(0).body().isInstanceOf(byte[].class);

        Object json = template.requestBody("direct:marshal", in);
        String jsonString = context.getTypeConverter().convertTo(String.class, json);
        JSONObject obj = (JSONObject) JSONSerializer.toJSON(jsonString);
        assertEquals("JSON must contain 1 top-level element", 1, obj.entrySet().size());
        assertTrue("Top-level element must be named root", obj.has("root"));

        mockJSON.assertIsSatisfied();
    }
View Full Code Here

        mockJSON.expectedMessageCount(1);
        mockJSON.message(0).body().isInstanceOf(byte[].class);

        Object json = template.requestBody("direct:marshal", in);
        String jsonString = context.getTypeConverter().convertTo(String.class, json);
        JSONObject obj = (JSONObject) JSONSerializer.toJSON(jsonString);
        assertEquals("JSON must contain 1 top-level element", 1, obj.entrySet().size());
        assertTrue("Top-level element must be named root", obj.has("root"));

        mockJSON.assertIsSatisfied();
    }
View Full Code Here

        mockJSON.expectedMessageCount(1);
        mockJSON.message(0).body().isInstanceOf(byte[].class);

        Object json = template.requestBody("direct:marshal", in);
        String jsonString = context.getTypeConverter().convertTo(String.class, json);
        JSONObject obj = (JSONObject) JSONSerializer.toJSON(jsonString);
        assertEquals("JSON must contain 1 top-level element", 1, obj.entrySet().size());
        assertTrue("Top-level element must be named root", obj.has("root"));
        // check that no child of the top-level element has a colon in its key,
        // which would denote that
        // a namespace prefix exists
        for (Object key : obj.getJSONObject("root").keySet()) {
            assertFalse("A key contains a colon", ((String) key).contains(":"));
        }

        mockJSON.assertIsSatisfied();
    }
View Full Code Here

       
        effect.append("\"").append(this.elementId).append("\"");
       
       
        if (!this.options.isEmpty()) {
            JSONObject json = JSONObject.fromMap(this.options);
            effect.append(",").append(json.toString());
        }
       
        effect.append(");");
       
        return effect.toString();
View Full Code Here

       
        effect.append("\"").append(this.elementId).append("\"");
       
       
        if (!this.options.isEmpty()) {
            JSONObject json = JSONObject.fromMap(this.options);
            effect.append(",").append(json.toString());
        }
       
        effect.append(");");
       
        return effect.toString();
View Full Code Here

                effect.append(",").append(param);
            }
        }
       
        if (!this.options.isEmpty()) {
            JSONObject json = JSONObject.fromMap(this.options);
            effect.append(",").append(json.toString());
        }
       
        effect.append(");");
       
        return effect.toString();
View Full Code Here

       
        effect.append("\"").append(this.elementId).append("\"");
       
       
        if (!this.options.isEmpty()) {
            JSONObject json = JSONObject.fromMap(this.options);
            effect.append(",").append(json.toString());
        }
       
        effect.append(");");
       
        return effect.toString();
View Full Code Here

   
    private void initEvent(AjaxEvent event, HttpServletRequest request) {
        String paramsString = request.getParameter(this.jsonParamsParameter);
        if (paramsString != null) {
            Map<String, String> parameters = new HashMap<String, String>();
            JSONObject json = JSONObject.fromString(paramsString);
            Iterator keys = json.keys();
            while (keys.hasNext()) {
                String key = keys.next().toString();
                parameters.put(key, json.opt(key).toString());
            }
            event.setParameters(parameters);
        }
       
        event.setElementName(request.getParameter(this.elementParameter));
View Full Code Here

TOP

Related Classes of net.sf.json.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.