Package net.sf.json

Examples of net.sf.json.JSONObject


  }
 
  public void testGo() throws Exception{
    action.setSearchUrl(url);
    assertEquals(ActionSupport.SUCCESS,action.execute());
    JSONObject jsonObj = action.getJsonResult();
    assertNotNull(jsonObj.toString());   
  }
View Full Code Here


  private static final GeometryFactory factory = new GeometryFactory();
 
  @Override
  public Object convertFromString(Map ctx, String[] args, Class toType) {
    String gMarkerJson = ((String[])args)[0];
    JSONObject jsonObj = JSONObject.fromObject(gMarkerJson);
    if(toType == PointMarker.class){
      PointMarker pm = new PointMarker();  
      pm.setNotes(jsonObj.getString("notes"));
      pm.setId(jsonObj.getInt("id"));
      pm.setMarkerIconId(jsonObj.getInt("iconId"));
      Point pt = parsePoint(jsonObj.getString("point"));
      if(pt != null){
        pm.setPoint(pt);
      }         
      return pm;
    }
View Full Code Here

      map.put("id",pm.getId());
      map.put("notes",pm.getNotes());
      map.put("point",pm.getPoint().getX()+","+pm.getPoint().getY());
      map.put("iconId",pm.getMarkerIconId());
    }
    JSONObject json = JSONObject.fromObject(map);
    return json.toString();
  }
View Full Code Here

    return SUCCESS;
  }
 
  public JSON getJsonResult(){
    if(bookmark == null){
      return new JSONObject();     
    }else{
      Map<String,Object> bookmarkMap = FormatUtil.getBookmarkAsMap(bookmark);
      return JSONSerializer.toJSON(bookmarkMap);
    }
  }
View Full Code Here

        {
            Object result = null;

            if ( json != null )
            {
                JSONObject jsonObject = JSONObject.fromObject( json );

                if ( !jsonObject.isNullObject() )
                {
                    if ( jsonObject.has( "uniqueName" ) )
                    {
                        result = JSONObject.toBean( jsonObject, Class.forName( jsonObject.getString( "uniqueName" ) ) );
                    }
                    else
                    {
                        result = JSONSerializer.toJava( jsonObject );
                    }
View Full Code Here

        }
    }

    public static JSONObject getJSONObject(JSONObject obj, String key, JSONObject... default_value) {
        try {
            JSONObject object = obj.getJSONObject(key);
            if (object == null || object.size() == 0) return default_value.length == 0 ? null : default_value[0];
            return object;
        } catch (Exception e) {
            return default_value.length == 0 ? null : default_value[0];
        }
View Full Code Here

    @Test
    public void testNewInstance_shouldGetBasicInformation()
            throws Exception {
        j.createWebClient().executeOnServer(new Callable<Object>() {
            public Void call() throws Exception {
                JSONObject form = new JSONObject();
                form.put("project_content_type", "default");
                form.put("project_recipient_list", "ashlux@gmail.com");
                form.put("project_default_subject", "Make millions in Nigeria");
                form.put("project_default_content", "Give me a $1000 check and I'll mail you back $5000!!!");
                form.put("project_attachments", "");
                form.put("project_presend_script", "");
                form.put("project_replyto", "");

                ExtendedEmailPublisherDescriptor descriptor = new ExtendedEmailPublisherDescriptor();
                publisher = (ExtendedEmailPublisher) descriptor.newInstance(Stapler.getCurrentRequest(), form);

                assertEquals("default", publisher.contentType);
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.expectedBodiesReceived(Arrays.asList(expectedBody, expectedBody, expectedBody));

        // start bombarding the route
        Object json = template.requestBody("direct:marshal", inDOM);
        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.requestBody("direct:marshal", inSAX);
        template.requestBody("direct:marshal", inDocument);

        mockJSON.assertIsSatisfied();
    }
View Full Code Here

        mockXML.expectedMessageCount(1);
        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

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.