當前位置: 首頁>>代碼示例>>Java>>正文


Java JSONObject.put方法代碼示例

本文整理匯總了Java中org.json.simple.JSONObject.put方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONObject.put方法的具體用法?Java JSONObject.put怎麽用?Java JSONObject.put使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.json.simple.JSONObject的用法示例。


在下文中一共展示了JSONObject.put方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: decorate

import org.json.simple.JSONObject; //導入方法依賴的package包/類
/**
 * @see org.alfresco.repo.jscript.app.PropertyDecorator#decorate(org.alfresco.service.namespace.QName, org.alfresco.service.cmr.repository.NodeRef, java.io.Serializable)
 */
@SuppressWarnings("unchecked")
public JSONAware decorate(QName propertyName, NodeRef nodeRef, Serializable value)
{
    Collection<NodeRef> collection = (Collection<NodeRef>)value;
    JSONArray array = new JSONArray();

    for (NodeRef obj : collection)
    {
        try
        {
            JSONObject jsonObj = new JSONObject();
            jsonObj.put("name", this.nodeService.getProperty(obj, ContentModel.PROP_NAME));
            jsonObj.put("nodeRef", obj.toString());
            array.add(jsonObj);
        }
        catch (InvalidNodeRefException e)
        {
            logger.warn("Tag with nodeRef " + obj.toString() + " does not exist.");
        }
    }

    return array;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:27,代碼來源:TagPropertyDecorator.java

示例2: projectTraverser

import org.json.simple.JSONObject; //導入方法依賴的package包/類
@Override
public JSONObject projectTraverser(final Traverser.Admin<Path> traverser) {
    final JSONObject root = new JSONObject();
    JSONObject currentNode = root;
    for (final Object object : traverser.get()) {
        if (object instanceof Map) {
            for(final Map.Entry entry : (Set<Map.Entry>)((Map)object).entrySet()) {
                if(entry.getKey().equals(T.id))
                    currentNode.put(T.id.getAccessor(),entry.getValue());
                else if(entry.getKey().equals(T.label))
                    currentNode.put(T.label.getAccessor(),entry.getValue());
                else
                    currentNode.put(entry.getKey(),entry.getValue());
            }
        }
        else if (object instanceof String)
            currentNode.put(object, currentNode = new JSONObject());
    }
    return root;
}
 
開發者ID:okram,項目名稱:mongodb-gremlin,代碼行數:21,代碼來源:MongoDBQueryStep.java

示例3: JSONObject

import org.json.simple.JSONObject; //導入方法依賴的package包/類
/**
 * ComplexPropertyのTypeがEdmDateTimeの場合ユーザデータに最小値より小さい値を指定して400エラーとなること.
 */
@SuppressWarnings("unchecked")
@Test
public final void ComplexPropertyのTypeがEdmDateTimeの場合ユーザデータに最小値より小さい値を指定して400エラーとなること() {
    // リクエストボディを設定
    JSONObject complexBody = new JSONObject();
    complexBody.put(PROP_NAME, "/Date(" + (ODataUtils.DATETIME_MIN - 1) + ")/");
    JSONObject body = new JSONObject();
    body.put("__id", USERDATA_ID);
    body.put(PROP_NAME, complexBody);

    try {
        createEntities(EdmSimpleType.DATETIME.getFullyQualifiedTypeName());

        // ユーザデータ作成
        TResponse response = createUserData(body, HttpStatus.SC_BAD_REQUEST,
                cellName, boxName, COL_NAME, ENTITY_TYPE_NAME);

        JSONObject json = response.bodyAsJson();
        String code = json.get("code").toString();
        assertEquals("PR400-OD-0006", code);
    } finally {
        deleteEntities();
    }
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:28,代碼來源:UserDataComplexPropertyDateTimeTest.java

示例4: setPropertyText

import org.json.simple.JSONObject; //導入方法依賴的package包/類
/**
 * Sets a new text of the specified property.
 *
 * @param styleId ID of the style to modify.
 * @param propertyIndex index of the property in the style.
 * @param propertyText text of the property in the form {@code name:value;}.
 * @param overwrite if {@code true} then the property at the given position
 * is overwritten, otherwise it is inserted.
 * @return the resulting style after the property text modification.
 */
public Style setPropertyText(StyleId styleId, int propertyIndex, String propertyText, boolean overwrite) {
    Style resultingStyle = null;
    JSONObject params = new JSONObject();
    params.put("styleId", styleId.toJSONObject()); // NOI18N
    params.put("propertyIndex", propertyIndex); // NOI18N
    params.put("text", propertyText); // NOI18N
    params.put("overwrite", overwrite); // NOI18N
    Response response = transport.sendBlockingCommand(new Command("CSS.setPropertyText", params)); // NOI18N
    if (response != null) {
        JSONObject result = response.getResult();
        if (result != null) {
            JSONObject style = (JSONObject)result.get("style"); // NOI18N
            resultingStyle = new Style(style);
        }
    }
    return resultingStyle;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:CSS.java

示例5: processRequest

import org.json.simple.JSONObject; //導入方法依賴的package包/類
@Override
JSONStreamAware processRequest(HttpServletRequest req) throws NxtException {

    int firstIndex = ParameterParser.getFirstIndex(req);
    int lastIndex = ParameterParser.getLastIndex(req);
    if (lastIndex < 0 || lastIndex - firstIndex > 99) {
        lastIndex = firstIndex + 99;
    }

    boolean includeTransactions = "true".equalsIgnoreCase(req.getParameter("includeTransactions"));

    JSONArray blocks = new JSONArray();
    try (DbIterator<? extends Block> iterator = Nxt.getBlockchain().getBlocks(firstIndex, lastIndex)) {
        while (iterator.hasNext()) {
            Block block = iterator.next();
            blocks.add(JSONData.block(block, includeTransactions));
        }
    }

    JSONObject response = new JSONObject();
    response.put("blocks", blocks);

    return response;
}
 
開發者ID:muhatzg,項目名稱:burstcoin,代碼行數:25,代碼來源:GetBlocks.java

示例6: createUserDataList

import org.json.simple.JSONObject; //導入方法依賴的package包/類
/**
 * ユーザデータの一覧を作成.
 */
@SuppressWarnings("unchecked")
public void createUserDataList() {
    // リクエストボディを設定
    JSONObject body = new JSONObject();
    body.put("__id", userDataId201);
    body.put("dynamicProperty1", "dynamicPropertyValue1");
    body.put("dynamicProperty2", "dynamicPropertyValue2");
    body.put("dynamicProperty3", "dynamicPropertyValue3");

    JSONObject body2 = new JSONObject();
    body2.put("__id", userDataId202);
    body2.put("dynamicProperty1", "dynamicPropertyValueA");
    body2.put("dynamicProperty2", "dynamicPropertyValueB");
    body2.put("dynamicProperty3", "dynamicPropertyValueC");

    // ユーザデータ作成
    createUserData(body, HttpStatus.SC_CREATED);
    createUserData(body2, HttpStatus.SC_CREATED);
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:23,代碼來源:UserDataListTest.java

示例7: getRequestJsonObject

import org.json.simple.JSONObject; //導入方法依賴的package包/類
protected JSONObject getRequestJsonObject() {
    JSONObject chart = new JSONObject();
    chart.put("chartId", chartId);
    try {
        JSONObject data = getChartData();
        if (data == null) {
            // If the data is null we don't send the chart.
            return null;
        }
        chart.put("data", data);
    } catch (Throwable t) {
        if (logFailedRequests) {
            Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
        }
        return null;
    }
    return chart;
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:19,代碼來源:Metrics.java

示例8: getChartData

import org.json.simple.JSONObject; //導入方法依賴的package包/類
@Override
protected JSONObject getChartData() {
    JSONObject data = new JSONObject();
    JSONObject values = new JSONObject();
    HashMap<Country, Integer> map = getValues(new HashMap<Country, Integer>());
    if (map == null || map.isEmpty()) {
        // Null = skip the chart
        return null;
    }
    boolean allSkipped = true;
    for (Map.Entry<Country, Integer> entry : map.entrySet()) {
        if (entry.getValue() == 0) {
            continue; // Skip this invalid
        }
        allSkipped = false;
        values.put(entry.getKey().getCountryIsoTag(), entry.getValue());
    }
    if (allSkipped) {
        // Null = skip the chart
        return null;
    }
    data.put("values", values);
    return data;
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:25,代碼來源:Metrics.java

示例9: toJson

import org.json.simple.JSONObject; //導入方法依賴的package包/類
/**
 * Util function.
 * Creates a json object that represent the class.
 *
 * @return The {@link JSONObject} that represent the class
 */
public JSONObject toJson(){

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("types", allTypes);
    jsonObject.put("htmlObjectsFileName",htmlObjectsFileName );

    return jsonObject;
}
 
開發者ID:CheckPoint-APIs-Team,項目名稱:ShowPolicyPackage,代碼行數:15,代碼來源:ObjectsInUse.java

示例10: putMyJSON

import org.json.simple.JSONObject; //導入方法依賴的package包/類
@Override
void putMyJSON(JSONObject attachment) {
    attachment.put("purchase", Convert.toUnsignedLong(purchaseId));
    attachment.put("goodsData", Convert.toHexString(goods.getData()));
    attachment.put("goodsNonce", Convert.toHexString(goods.getNonce()));
    attachment.put("discountNQT", discountNQT);
    attachment.put("goodsIsText", goodsIsText);
}
 
開發者ID:muhatzg,項目名稱:burstcoin,代碼行數:9,代碼來源:Attachment.java

示例11: getChartData

import org.json.simple.JSONObject; //導入方法依賴的package包/類
@Override
protected JSONObject getChartData() throws Exception {
    JSONObject data = new JSONObject();
    int value = callable.call();
    if (value == 0) {
        // Null = skip the chart
        return null;
    }
    data.put("value", value);
    return data;
}
 
開發者ID:Slaymd,項目名稱:CaulCrafting,代碼行數:12,代碼來源:Metrics.java

示例12: createMultiUserDataList

import org.json.simple.JSONObject; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void createMultiUserDataList() {
    JSONObject body = new JSONObject();
    body.put("__id", userDataId201);
    body.put("dynamicProperty", "dynamicPropertyValue");
    body.put("secondDynamicProperty", "secondDynamicPropertyValue");
    body.put("nullProp", null);
    body.put("intProperty", 123);
    body.put("floatProperty", 123.123);
    body.put("trueProperty", true);
    body.put("falseProperty", false);
    body.put("nullStringProperty", "null");
    body.put("intStringProperty", "123");
    body.put("floatStringProperty", "123.123");
    body.put("trueStringProperty", "true");
    body.put("falseStringProperty", "false");
    body.put("onlyExistProperty201", "exist201");

    JSONObject body2 = new JSONObject();
    body2.put("__id", userDataId202);
    body2.put("dynamicProperty", "dynamicPropertyValue2");
    body2.put("secondDynamicProperty", "secondDynamicPropertyValue2");
    body2.put("nullProp", "nullString2");
    body2.put("intProperty", 1234);
    body2.put("floatProperty", 123.1234);
    body2.put("trueProperty", true);
    body2.put("falseProperty", false);
    body2.put("nullStringProperty", "null");
    body2.put("intStringProperty", "1234");
    body2.put("floatStringProperty", "123.1234");
    body2.put("trueStringProperty", "true");
    body2.put("falseStringProperty", "false");
    body.put("onlyExistProperty202", "exist202");

    // ユーザデータ作成
    createUserData(body, HttpStatus.SC_CREATED);
    createUserData(body2, HttpStatus.SC_CREATED);
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:39,代碼來源:UserDataListSelectTest.java

示例13: createEntities

import org.json.simple.JSONObject; //導入方法依賴的package包/類
/**
 * Double型配列のデータに最大製限値より大きい値が含まれている場合に登録できないこと.
 * @throws ParseException パース例外.
 */
@SuppressWarnings("unchecked")
@Test
public final void Double型配列のデータに最大製限値より大きい値が含まれている場合に登録できないこと() throws ParseException {
    String userdataId1 = "doubleTest1";

    try {
        createEntities(EdmSimpleType.DOUBLE.getFullyQualifiedTypeName(), "1.79E308");
        // complexTypeProperty作成
        UserDataUtils.createComplexTypeProperty(cellName, boxName, COL_NAME, "listDoubleProperty",
                COMPLEX_TYPE_NAME,
                EdmSimpleType.DOUBLE.getFullyQualifiedTypeName(), true, null, "List");

        // Double型で登録・取得可能なこと
        JSONArray reqBody = (JSONArray) new JSONParser().parse("[123.456,-567.89,1,\"9.123456789\",1.791E308]");
        JSONObject complexBody = new JSONObject();
        complexBody.put("listDoubleProperty", reqBody);
        JSONObject body = new JSONObject();
        body.put("__id", userdataId1);
        body.put(PROP_NAME, complexBody);

        // ユーザデータ作成
        UserDataUtils.create(AbstractCase.MASTER_TOKEN_NAME, HttpStatus.SC_BAD_REQUEST, body,
                cellName, boxName, COL_NAME, ENTITY_TYPE_NAME);

        // ユーザデータ一件取得
        getUserData(cellName, boxName, COL_NAME, ENTITY_TYPE_NAME, userdataId1,
                Setup.MASTER_TOKEN_NAME, HttpStatus.SC_NOT_FOUND);
    } finally {
        // ユーザデータ削除
        deleteUserData(userdataId1);

        String ctplocationUrl = UrlUtils.complexTypeProperty(cellName, boxName, COL_NAME, "listDoubleProperty",
                COMPLEX_TYPE_NAME);
        ODataCommon.deleteOdataResource(ctplocationUrl);
        deleteEntities();
    }
}
 
開發者ID:personium,項目名稱:personium-core,代碼行數:42,代碼來源:UserDataDeclaredDoubleComplexTypePropertyTest.java

示例14: getChartData

import org.json.simple.JSONObject; //導入方法依賴的package包/類
@Override
protected JSONObject getChartData() {
    JSONObject data = new JSONObject();
    Country value = getValue();

    if (value == null) {
        // Null = skip the chart
        return null;
    }
    data.put("value", value.getCountryIsoTag());
    return data;
}
 
開發者ID:Soldier233,項目名稱:ArchersBattle,代碼行數:13,代碼來源:Metrics.java

示例15: getPluginData

import org.json.simple.JSONObject; //導入方法依賴的package包/類
/**
 * Gets the plugin specific data.
 * This method is called using Reflection.
 *
 * @return The plugin specific data.
 */
public JSONObject getPluginData() {
    JSONObject data = new JSONObject();

    String pluginName = plugin.getDescription().getName();
    String pluginVersion = plugin.getDescription().getVersion();

    data.put("pluginName", pluginName); // Append the name of the plugin
    data.put("pluginVersion", pluginVersion); // Append the version of the plugin
    JSONArray customCharts = new JSONArray();
    data.put("customCharts", customCharts);

    return data;
}
 
開發者ID:BtoBastian,項目名稱:bStats-Metrics,代碼行數:20,代碼來源:MetricsLite.java


注:本文中的org.json.simple.JSONObject.put方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。