当前位置: 首页>>代码示例>>Java>>正文


Java JSONObject.getNames方法代码示例

本文整理汇总了Java中org.json.JSONObject.getNames方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.getNames方法的具体用法?Java JSONObject.getNames怎么用?Java JSONObject.getNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.json.JSONObject的用法示例。


在下文中一共展示了JSONObject.getNames方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getContainerName

import org.json.JSONObject; //导入方法依赖的package包/类
@Override public String getContainerName(JSONObject container) throws JSONException, ObjectMapException {
    // For a container we shall use urp to generate the name
    JSONObject attributes = container.getJSONObject("attributes");
    String name;
    if (attributes.has("suggestedName")) {
        name = attributes.getString("suggestedName");
    } else {
        JSONObject urp = container.getJSONObject("urp");
        StringBuilder sb = new StringBuilder();
        String[] keys = JSONObject.getNames(urp);
        for (String key : keys) {
            sb.append(urp.get(key).toString()).append(':');
        }
        sb.setLength(sb.length() - 1);
        name = sb.toString();
    }
    return getName(container, name);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:19,代码来源:ObjectMapNamingStrategy.java

示例2: fromJSONObject

import org.json.JSONObject; //导入方法依赖的package包/类
public void fromJSONObject(JSONObject jsonTuple)
{
    this.reset();
    
    try {
        String[] fieldnames = JSONObject.getNames(jsonTuple);
        for(int index=0; index<fieldnames.length; index++)
        {
            String fieldname = fieldnames[index];
            Object fieldvalue = jsonTuple.get(fieldname);
            this.addField(fieldname, fieldvalue);
        }
    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:18,代码来源:Tuple.java

示例3: normalizeObject

import org.json.JSONObject; //导入方法依赖的package包/类
protected JSONObject normalizeObject(JSONObject obj) {
    LOGGER.debug("NORM: " + obj.toString());
    for (String key : JSONObject.getNames(obj)) {
        JSONObject subtree = obj.optJSONObject(key);
        if (subtree != null) {
            if (subtree.has(ARRAY)) {
                // Set the array as the direct value
                JSONArray subarray = subtree.getJSONArray(ARRAY);
                obj.put(key, subarray);
                LOGGER.debug("recurse with {}: {}", key, subtree.toString());
            }

            // See if there's more to do in this subtree
            normalizeObject(subtree);
        }
    }

    return obj;
}
 
开发者ID:vrk-kpa,项目名称:xrd4j,代码行数:20,代码来源:XMLToJSONConverter.java

示例4: asProperties

import org.json.JSONObject; //导入方法依赖的package包/类
public static Properties asProperties(JSONObject jsonObject) {
    Properties r = new Properties();
    String[] names = JSONObject.getNames(jsonObject);
    if (names != null) {
        for (String name : names) {
            r.setProperty(name, jsonObject.get(name).toString());
        }
    }
    return r;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:11,代码来源:PropertyHelper.java

示例5: compareProperties

import org.json.JSONObject; //导入方法依赖的package包/类
private void compareProperties(JSONObject before, JSONObject after) throws JSONException
{
    for (String name : JSONObject.getNames(after))
    {
        if (before.has(name))
        {
            if (before.get(name) instanceof JSONArray)
            {
                for (int i = 0; i < before.getJSONArray(name).length(); i++)
                {
                    assertEquals(before.getJSONArray(name).get(i), after.getJSONArray(name).get(i));
                }
            }
            else
            {
                assertEquals(before.get(name), after.get(name));
            }
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:21,代码来源:AbstractWorkflowRestApiTest.java

示例6: toMap

import org.json.JSONObject; //导入方法依赖的package包/类
public static Map<String, Object> toMap(JSONObject object) {
    Map<String, Object> map = new HashMap<>();
    
    String[] fields = JSONObject.getNames(object);
    
    for (String field : fields) {
        Object entry = object.get(field);
        
        if (entry instanceof JSONObject) {
            map.put(field, toMap((JSONObject) entry));
        } else if (entry instanceof JSONArray) {
            map.put(field, toCollection((JSONArray) entry));
        } else {
            map.put(field, entry);
        }
    }
    
    return map;
}
 
开发者ID:shawlaf,项目名称:Banmanager,代码行数:20,代码来源:JSONUtils.java

示例7: parseJSONSettings

import org.json.JSONObject; //导入方法依赖的package包/类
/**
 * Takes jsonSettings parameter and inserts all Key-Value pairs into the settings map
 * <p>
 * Recursively passes child json objects into itself with there path as the new base path. Utilizing {@link
 * ApplicationSettings#bindPath(String, String)} to link the new paths to the base path.
 * <p>
 * NOTE: Expects a json object with keys mapping to JSON objects or Strings ONLY. It will fail fast otherwise.
 *
 * @param jsonSettings
 * 		JSON Object of settings file
 * @param basePath
 * 		Starting path to prefix onto new keys
 */
private static void parseJSONSettings( JSONObject jsonSettings, String basePath )
{
	for ( String key : JSONObject.getNames(jsonSettings) )
	{
		Object value = jsonSettings.get(key);
		if ( value instanceof String )
		{
			settings.put(bindPath(basePath, key), (String) value);
		} else
		{
			parseJSONSettings(jsonSettings.getJSONObject(key), bindPath(basePath, key));
		}
	}
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:28,代码来源:ApplicationSettings.java

示例8: resetInstance

import org.json.JSONObject; //导入方法依赖的package包/类
public void resetInstance(AbstractPreferences oldInstance) {
    listeners = oldInstance.listeners;
    String[] names = JSONObject.getNames(prefs);
    if (names != null) {
        for (String section : names) {
            firePreferenceChange(section);
        }
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:10,代码来源:AbstractPreferences.java

示例9: toCSS

import org.json.JSONObject; //导入方法依赖的package包/类
public static String toCSS(JSONObject urp) {
    Properties props = new Properties();
    String[] names = JSONObject.getNames(urp);
    for (String prop : names) {
        props.setProperty(prop, urp.get(prop).toString());
    }
    return toCSS(props);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:9,代码来源:PropertyHelper.java

示例10: fromJSONObject

import org.json.JSONObject; //导入方法依赖的package包/类
public void fromJSONObject(JSONObject jsonBatch) {
    this.reset();

    try {
        // get id
        long batchid = jsonBatch.getLong("ID");
        this.m_id = batchid;
        // get timestamp
        this.m_timestamp = jsonBatch.getLong("TIMESTAMP");
        this.m_endtimestamp = jsonBatch.getLong("ENDTIMESTAMP");

        JSONArray jsonBatchTuples = jsonBatch.getJSONArray("TUPLES");

        JSONObject jsonTuple;
        for (int i = 0; i < jsonBatchTuples.length(); i++) {
            jsonTuple = jsonBatchTuples.getJSONObject(i);

            Tuple tuple = new Tuple();
            String[] fieldnames = JSONObject.getNames(jsonTuple);

            for (int index = 0; index < fieldnames.length; index++) {
                String fieldname = fieldnames[index];
                Object fieldvalue = jsonTuple.get(fieldname);

                tuple.addField(fieldname, fieldvalue);
            }
            this.addTuple(tuple);
        }

    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:36,代码来源:Batch.java

示例11: search

import org.json.JSONObject; //导入方法依赖的package包/类
public boolean search(String find) {
    for (String jsonName : JSONObject.getNames(json)) {
        Object value = json.get(jsonName);
        if (searchMatch(find, value))
            return true;
    }
    return false;
}
 
开发者ID:limberest,项目名称:limberest,代码行数:9,代码来源:JsonMatcher.java

示例12: ServiceSummary

import org.json.JSONObject; //导入方法依赖的package包/类
public ServiceSummary(JSONObject json) throws JSONException {
    if (json.has("publicUserId"))
        this.publicUserId = json.getString("publicUserId");
    if (json.has("requestId"))
        this.requestId = json.getString("requestId");
    if (json.has("microservices")) {
        JSONObject summaryJson = json.getJSONObject("microservices");
        for (String microservice : JSONObject.getNames(summaryJson)) {
            Microservice microInvokes = new Microservice(microservice, summaryJson.getJSONObject(microservice));
            microserviceSummaries.add(microInvokes);
        }
    }
}
 
开发者ID:CenturyLinkCloud,项目名称:mdw-demo,代码行数:14,代码来源:ServiceSummary.java

示例13: run

import org.json.JSONObject; //导入方法依赖的package包/类
public Result run(String[] args, MessageReceivedEvent e) {
	
	//Request information from Mojang
	String request = RequestUtils.get("https://status.mojang.com/check");
	if (request == null) {
		return new Result(Outcome.ERROR, ":x: The Mojang API could not be reached.");
	}
	
	Color color = Color.GREEN;
	//Iterate over response sections
	ArrayList<String> responses = new ArrayList<String>();
	JSONArray status = new JSONArray(request);
	for (int i = 0; i < status.length(); i++) {
		
		//Fetch the response
		JSONObject json = status.getJSONObject(i);
		String[] names = JSONObject.getNames(json);
		String response = json.getString(names[0]);
		
		//Parse the response
		String output = ":x:";
		if (response.equals("green")) {
			output = ":white_check_mark:";
		} else if (response.equals("yellow")) {
			output = ":warning:";
			if (color != Color.RED) {
				color = Color.YELLOW;
			}
		} else {
			color = Color.RED;
		}
		
		responses.add(output);
	}
	
	//Build message
	String m = "**Minecraft:** " + responses.get(0) +
		"\n" + "**Skins:** " + responses.get(4) +
		"\n" + "**Textures:** " + responses.get(8) +
		"\n" + "**Session:** " + responses.get(1) +
		"\n" + "**Session Server:** " + responses.get(6) +
		"\n" + "**Accounts:** " + responses.get(2) +
		"\n" + "**Auth:** " + responses.get(3) +
		"\n" + "**Auth Server:** " + responses.get(5) +
		"\n" + "**Mojang:** " + responses.get(9) +
		"\n" + "**Mojang API:** " + responses.get(7);
	
	MessageEmbed me = MessageUtils.embedMessage("Minecraft Status", null, m, color);
	
	return new Result(Outcome.SUCCESS, me);
}
 
开发者ID:Tisawesomeness,项目名称:Minecord,代码行数:52,代码来源:StatusCommand.java

示例14: incPageCommentCount

import org.json.JSONObject; //导入方法依赖的package包/类
/**
 * Page comment count +1 for an page specified by the given page id.
 *
 * @param pageId
 *            the given page id
 * @throws JSONException
 *             json exception
 * @throws RepositoryException
 *             repository exception
 */
public void incPageCommentCount(final String pageId) throws JSONException, RepositoryException {
	final JSONObject page = pageDao.get(pageId);
	final JSONObject newPage = new JSONObject(page, JSONObject.getNames(page));
	final int commentCnt = page.getInt(Page.PAGE_COMMENT_COUNT);

	newPage.put(Page.PAGE_COMMENT_COUNT, commentCnt + 1);
	pageDao.update(pageId, newPage);
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:19,代码来源:CommentMgmtService.java

示例15: decPageCommentCount

import org.json.JSONObject; //导入方法依赖的package包/类
/**
 * Page comment count -1 for an page specified by the given page id.
 *
 * @param pageId
 *            the given page id
 * @throws JSONException
 *             json exception
 * @throws RepositoryException
 *             repository exception
 */
private void decPageCommentCount(final String pageId) throws JSONException, RepositoryException {
	final JSONObject page = pageDao.get(pageId);
	final JSONObject newPage = new JSONObject(page, JSONObject.getNames(page));
	final int commentCnt = page.getInt(Page.PAGE_COMMENT_COUNT);

	newPage.put(Page.PAGE_COMMENT_COUNT, commentCnt - 1);
	pageDao.update(pageId, newPage);
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:19,代码来源:CommentMgmtService.java


注:本文中的org.json.JSONObject.getNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。