Package net.sf.json

Examples of net.sf.json.JSONObject.entrySet()


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

        Object json = template.requestBody("direct:marshalInline", 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:unmarshalInline", jsonString);

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


        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()) {
View Full Code Here

        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

            writer.endElement();
        } else {
            writer.writeElementText("<" + name);

            JSONObject attrs = object.getJSONObject("attributes");
            for (Object attr : attrs.entrySet()) {
                Map.Entry<?, ?> entry = (Map.Entry<?, ?>)attr;
                String attrname = (String)entry.getKey();
                String value = (String)entry.getValue();
                writer.writeElementText(" " + attrname + "=\"" + value + "\"");
            }
View Full Code Here

            String streamKey = stream.getKey();
            Map<String, String> streamMap = stream.getValue();
            for (Map.Entry<String, String> entry : streamMap.entrySet()) {
                streamJson.put(entry.getKey(), entry.getValue());
            }
            if (streamJson.entrySet().size() > 0) {
                dataStream.put(streamKey, streamJson);
            }
           
        }
        if (dataStream.entrySet().size() > 0) {
View Full Code Here

          for (Map.Entry<String, Map<String, String>> entry: metsObj.getDataStreamsMap().entrySet()) {
              JSONObject stream = new JSONObject();
              for (Map.Entry<String, String> streamEntry: entry.getValue().entrySet()) {
                  stream.put(streamEntry.getKey(), streamEntry.getValue());
              }
              if (stream.entrySet().size() > 0) {
                  dataStream.put(entry.getKey(), stream);
              }
          }
          if (dataStream.size() > 0) {
              mo.put("dataStream", dataStream);
View Full Code Here

  }

  public JSONObject processQueryParameters(HttpSession session, JSONObject json) {
    JSONObject tables = json.getJSONObject("parameters").getJSONObject("qparams");
    log.info(tables.toString());
    for (Object tObj : tables.entrySet()) {
      JSONObject table = (JSONObject) tObj;
      for (Object tKey : table.keySet()) {
        System.out.println((String) tKey);
        JSONArray columns = (JSONArray) table.get(tKey);
View Full Code Here

        writer.endElement();
      } else {
        writer.writeElementText("<" + name);
     
        JSONObject attrs = object.getJSONObject("attributes");
        for (Object attr : attrs.entrySet()) {
          Map.Entry<?,?> entry = (Map.Entry<?,?>)attr;
          String attrname = (String) entry.getKey();
          String value = (String) entry.getValue();
          writer.writeElementText(" " + attrname + "=\"" + value + "\"");
        }
View Full Code Here

   * @return the morphed bean (a map)
   */
  public Object morph(Object bean) {
    Map<Object, Object> result = Maps.newHashMap();
    JSONObject jsonObject = (JSONObject) bean;
    for (Object entry : jsonObject.entrySet()) {
      result.put(((Entry)entry).getKey(), ((Entry)entry).getValue());
    }
    return result;
  }

View Full Code Here

        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

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.