Example usage for org.json.simple JSONObject toJSONString

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

Introduction

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

Prototype

public String toJSONString() 

Source Link

Usage

From source file:com.fujitsu.dc.test.utils.UserDataUtils.java

/**
 * NP???????.//from   w  w w.j  a  va  2s . c  o m
 * @param token 
 * @param code ??
 * @return ?
 */
@SuppressWarnings("unchecked")
public static TResponse createViaNP(String token, int code) {
    JSONObject body = new JSONObject();
    body.put("__id", "npdata");
    TResponse res = Http.request("box/odatacol/createNP.txt").with("cell", "testcell1").with("box", "box1")
            .with("collection", "setodata").with("entityType", "Price").with("id", "auth_test")
            .with("navPropName", "_Sales").with("accept", MediaType.APPLICATION_JSON)
            .with("contentType", MediaType.APPLICATION_JSON).with("token", token)
            .with("body", body.toJSONString()).returns().statusCode(code).debug();

    return res;
}

From source file:com.mcapanel.web.controllers.SettingsController.java

public boolean process() throws IOException {
    if (isMethod("POST")) {
        includeIndex(false);//from w  w  w. j  a  va  2  s.  c  o m
        mimeType("application/json");

        JSONObject obj = new JSONObject();

        if (canView()) {

        }

        response.getWriter().println(obj.toJSONString());

        return true;
    }

    return error();
}

From source file:cn.vlabs.umt.ui.servlet.OauthTokenServlet.java

public static String getUserAsJSON(LoginNameInfo info, User user, String passwordType) {
    JSONObject object = new JSONObject();
    object.put("umtId", user.getUmtId());
    putStringToJSON(object, "truename", user.getTrueName());
    putStringToJSON(object, "type", user.getType());
    putStringToJSON(object, "cstnetId", user.getCstnetId());
    putStringToJSON(object, "cstnetIdStatus", info.getStatus());
    putStringToJSON(object, "securityEmail", user.getSecurityEmail());
    putStringToJSON(object, "passwordType", passwordType);
    String[] emails = user.getSecondaryEmails();
    if (emails != null && emails.length > 0) {
        JSONArray ar = new JSONArray();
        for (int i = 0; i < emails.length; i++) {
            ar.add(emails[i]);//w  w  w.ja va  2  s  .c  om
        }
        object.put("secondaryEmails", ar);
    }
    return object.toJSONString();
}

From source file:com.raphfrk.craftproxyclient.net.protocol.p17xlogin.P17xLoginProtocol.java

@SuppressWarnings("unchecked")
@Override//w  w  w .  j  a v  a  2 s  .  com
public Packet getKick(String message) {
    JSONObject obj = new JSONObject();
    obj.put("text", message);
    return new P17xKick(0, obj.toJSONString());
}

From source file:com.fujitsu.dc.test.utils.UserDataUtils.java

/**
 * OData??????.//from   w w w . j  a v  a 2s  . c  o m
 * @param token 
 * @param code ??
 * @param body 
 * @param cell ??
 * @param box ??
 * @param collection ??
 * @param entityType 
 * @param id OData?UUID
 * @param ifMatch If-Match
 * @return ?
 */
public static TResponse merge(String token, int code, JSONObject body, String cell, String box,
        String collection, String entityType, String id, String ifMatch) {
    TResponse res = Http.request("box/odatacol/merge.txt").with("cell", cell).with("box", box)
            .with("collection", collection).with("entityType", entityType).with("id", id)
            .with("accept", MediaType.APPLICATION_JSON).with("contentType", MediaType.APPLICATION_JSON)
            .with("token", token).with("ifMatch", ifMatch).with("body", body.toJSONString()).returns()
            .statusCode(code).debug();
    return res;
}

From source file:org.kitodo.data.elasticsearch.index.type.RulesetType.java

@SuppressWarnings("unchecked")
@Override/*from  w ww.j a  v  a2s  .  co m*/
public HttpEntity createDocument(Ruleset ruleset) {

    JSONObject rulesetObject = new JSONObject();
    rulesetObject.put("title", ruleset.getTitle());
    rulesetObject.put("file", ruleset.getFile());
    rulesetObject.put("orderMetadataByRuleset", ruleset.isOrderMetadataByRuleset());
    rulesetObject.put("fileContent", "");

    return new NStringEntity(rulesetObject.toJSONString(), ContentType.APPLICATION_JSON);
}

From source file:com.fujitsu.dc.test.utils.UserDataUtils.java

/**
 * OData??????./*from w  ww .j  a v  a  2  s .c  om*/
 * @param token 
 * @param code ??
 * @param body 
 * @param cell ??
 * @param box ??
 * @param collection ??
 * @param entityType 
 * @param id OData?UUID
 * @param ifMatch If-Match
 * @return ?
 */
public static TResponse update(String token, int code, JSONObject body, String cell, String box,
        String collection, String entityType, String id, String ifMatch) {
    TResponse res = Http.request("box/odatacol/update.txt").with("cell", cell).with("box", box)
            .with("collection", collection).with("entityType", entityType).with("id", id)
            .with("accept", MediaType.APPLICATION_JSON).with("contentType", MediaType.APPLICATION_JSON)
            .with("token", token).with("ifMatch", ifMatch).with("body", body.toJSONString()).returns()
            .statusCode(code).debug();
    return res;
}

From source file:com.fujitsu.dc.test.utils.UserDataUtils.java

/**
 * ?MERGE?????.//from w  w w  .ja  va  2s.c  o m
 * @param token 
 * @param code ??
 * @return ?
 */
@SuppressWarnings("unchecked")
public static TResponse merge(String token, int code) {
    JSONObject body = new JSONObject();
    body.put("__id", "auth_test");
    body.put("prop", "prop");
    TResponse res = Http.request("box/odatacol/merge.txt").with("cell", "testcell1").with("box", "box1")
            .with("collection", "setodata").with("entityType", "Price").with("id", "auth_test")
            .with("accept", MediaType.APPLICATION_JSON).with("contentType", MediaType.APPLICATION_JSON)
            .with("token", token).with("ifMatch", "*").with("body", body.toJSONString()).returns()
            .statusCode(code).debug();
    return res;
}

From source file:com.facebook.tsdb.tsdash.server.TsdbServlet.java

@SuppressWarnings("unchecked")
protected String getErrorResponse(Throwable e) {
    JSONObject errObj = new JSONObject();
    errObj.put("error", e.getMessage());
    StringWriter stackTrace = new StringWriter();
    e.printStackTrace(new PrintWriter(stackTrace));
    errObj.put("stacktrace", stackTrace.toString());
    return errObj.toJSONString();
}

From source file:com.fujitsu.dc.test.utils.UserDataUtils.java

/**
 * ??????./*w w  w  .  ja  v  a 2 s  .  c  o m*/
 * @param token 
 * @param code ??
 * @return ?
 */
@SuppressWarnings("unchecked")
public static TResponse update(String token, int code) {
    JSONObject body = new JSONObject();
    body.put("__id", "auth_test");
    body.put("prop", "prop");
    TResponse res = Http.request("box/odatacol/update.txt").with("cell", "testcell1").with("box", "box1")
            .with("collection", "setodata").with("entityType", "Price").with("id", "auth_test")
            .with("accept", MediaType.APPLICATION_JSON).with("contentType", MediaType.APPLICATION_JSON)
            .with("token", token).with("ifMatch", "*").with("body", body.toJSONString()).returns()
            .statusCode(code).debug();
    return res;
}