Example usage for org.json.simple JSONObject put

List of usage examples for org.json.simple JSONObject put

Introduction

In this page you can find the example usage for org.json.simple JSONObject put.

Prototype

V put(K key, V value);

Source Link

Document

Associates the specified value with the specified key in this map (optional operation).

Usage

From source file:es.tid.fiware.fiwareconnectors.cygnus.backends.ckan.CKANResponseTest.java

/**
 * Sets up tests by creating a unique instance of the tested class, and by defining the behaviour of the mocked
 * classes./*from www  . j a  v  a 2s  .  c  om*/
 *  
 * @throws Exception
 */
@Before
public void setUp() throws Exception {
    // set up the instance of the tested class
    JSONObject obj = new JSONObject();
    obj.put("test", "test");
    response = new CKANResponse(obj, 200);
}

From source file:JSON.WriteProductJSON.java

public void buildJSON(String imageURL, String name, String price, String rating, String productURL) {

    JSONObject product1 = new JSONObject();
    product1.put("image", imageURL);
    product1.put("name", name);
    product1.put("cost", price);
    product1.put("good", rating);
    product1.put("buy", productURL);

    details.add(product1);//from  w ww. j a v  a2  s .c  o m
}

From source file:net.dbyrne.natenberg.Server.java

@SuppressWarnings("unchecked")
private JSONObject newErrorMsg(Exception e) {
    JSONObject error = new JSONObject();
    error.put("error", e.getClass() + ":" + e.getMessage());
    return error;
}

From source file:com.github.sourjson.translat.def.DateTranslater.java

@SuppressWarnings("unchecked")
@Override//  www. ja  v a 2 s  .  c  o  m
public @CheckForNull JSONObject serialize(Date obj, Type typeOnServer, AnnotatedElement el,
        @CheckForNull Object enclosing, SourJson json, double version) {
    JSONObject ret = new JSONObject();
    ret.put("GMT", formater.format(obj));
    return ret;
}

From source file:com.mobicage.rogerthat.form.GPSLocation.java

@Override
@SuppressWarnings("unchecked")
public JSONObject toJSONObject() {
    JSONObject result = new JSONObject();
    result.put("gps", this.gps);
    return result;
}

From source file:com.mobicage.rogerthat.form.FormResult.java

@SuppressWarnings("unchecked")
@Override//from w  w w  .java2  s  .c o  m
public JSONObject toJSONObject() {
    JSONObject obj = new JSONObject();
    obj.put("type", getType());
    obj.put("result", this.widget == null ? null : this.widget.toJSONObject());
    return obj;
}

From source file:net.duckling.ddl.web.api.APIAndroidMessagePullController.java

private void addMessage(AndroidMessageBean bean, JSONObject obj) {
    obj.put("messageType", bean.getType());
    if (bean.isNoMessage()) {
        return;/*www.ja v a2 s  . c om*/
    }
    obj.put("allMessage", bean.getMessageCount());
    obj.put("latestMessage", bean.getLatestCount());
    obj.put("message", bean.getMessage());
    obj.put("isMoreTeamMessage", bean.isMoreTeamMessage());
}

From source file:at.rocworks.oa4j.logger.data.base.DataItem.java

@SuppressWarnings("unchecked")
public JSONObject toJSONObject() {
    SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
    JSONObject obj = new JSONObject();
    obj.put("Name", dp.getFQN());
    obj.put("Time", fmt.format(getDate()));
    obj.put("TimeMS", getTimeMS());
    return obj;//from   w w  w  .ja va 2s .c  o  m
}

From source file:com.studevs.controllers.Index.java

@RequestMapping(value = "ajax_test")
@ResponseBody//from w  ww.  j  a v a2s  .c  o m
public String doRequest2() {

    //        JSONArray array = new JSONArray();
    //        
    //        JSONObject object1 = new JSONObject();
    //        object1.put("number", String.valueOf(new Random().nextInt() * 1000)+" 1");
    //        object1.put("date", new Date().toString()+" 1");
    //        
    //        JSONObject object2 = new JSONObject();
    //        object2.put("number", String.valueOf(new Random().nextInt() * 1000)+" 2");
    //        object2.put("date", new Date().toString()+" 2");

    JSONObject object3 = new JSONObject();
    object3.put("number", String.valueOf(new Random().nextInt() * 1000) + " 3");
    object3.put("date", new Date().toString() + " 3");

    //        array.add(object1);
    //        array.add(object2);
    //        array.add(object3);

    return object3.toJSONString();
}

From source file:de.root1.kad.smartvisu.AsyncReadRunnable.java

@Override
public void run() {
    try {/*  www  .j a v a  2s . c om*/
        String value = knx.read(address);
        if (value != null) {
            JSONObject jsonResponse = new JSONObject();
            JSONObject jsonData = new JSONObject();
            jsonData.put(address, value);
            jsonResponse.put(BackendServer.PARAM_DATA, jsonData);
            log.info("async response: {}", jsonResponse.toJSONString());
            sse.sendMessage(null, null, jsonResponse.toJSONString());
        } else {
            log.warn("Cannot read '" + address + "' async. Timeout?");
        }
    } catch (KnxServiceException ex) {
        log.error("Error reading data from '" + address + "'", ex);
    }
}