当前位置: 首页>>代码示例>>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;未经允许,请勿转载。