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


Java JsonRepresentation.getJsonObject方法代码示例

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


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

示例1: post

import org.restlet.ext.json.JsonRepresentation; //导入方法依赖的package包/类
@Post
public Representation post(JsonRepresentation jsonRep) {

	// handle request
	JSONObject request = jsonRep.getJsonObject();

	String username = request.getString("username");
	long userscore = request.getLong("score");
	
	System.out.println(username);
	System.out.println(userscore);
	
	Iterator userListIterator = Game.getInstance().getIterator();
	while (userListIterator.hasNext()) {
		User user = (User) userListIterator.next();

		if (user.getUsername().equals(username)) {
			user.setScore(userscore);
			break;
		}
	}

	// prepare and send response
	JSONArray response = new JSONArray(Game.getInstance().getListOfUsers());
	return new JsonRepresentation(response);
}
 
开发者ID:CodeGladiators,项目名称:CatchMeIfUCan,代码行数:27,代码来源:ScoreboardService.java

示例2: configure

import org.restlet.ext.json.JsonRepresentation; //导入方法依赖的package包/类
@Post
public void configure(final JsonRepresentation request) {
    final ExtensionConfigurationItem item = new ExtensionConfigurationItem(request.getJsonObject());
    final ExtensionTokenManager tokenManager = getTokenManager();

    if (tokenManager != null) {
        tokenManager.setAddresses(item.getHubBaseUrl(), item.getExtensionUrl(), item.getoAuthAuthorizeUrl(),
                item.getoAuthTokenUrl());
    } else {
        getResponse().setStatus(Status.SERVER_ERROR_INTERNAL);
    }
}
 
开发者ID:blackducksoftware,项目名称:hub-email-extension,代码行数:13,代码来源:OAuthConfigurationResource.java

示例3: post

import org.restlet.ext.json.JsonRepresentation; //导入方法依赖的package包/类
@Post
public Representation post(JsonRepresentation jsonRep) {

	JSONObject request = jsonRep.getJsonObject();
	String username = request.getString("username");
	System.out.println(username);
		
	Iterator userListIterator = Game.getInstance().getIterator();

	JSONObject response = new JSONObject();

	// check if user already exists
	while (userListIterator.hasNext()) {
		User user = (User) userListIterator.next();

		if (user.getUsername().equals(username)) {
			response.put("statusCode", 401);
			return new JsonRepresentation(response);
		}
	}

	// otherwise register user
	Game.getInstance().addUser(new User(username));

	response.put("username", username);
	response.put("statusCode", 200);

	return new JsonRepresentation(response);
}
 
开发者ID:CodeGladiators,项目名称:CatchMeIfUCan,代码行数:30,代码来源:RegisterUserService.java

示例4: updateFeature

import org.restlet.ext.json.JsonRepresentation; //导入方法依赖的package包/类
@Put
public void updateFeature(JsonRepresentation newFeatureRep) throws JSONException {
	// Locate the transaction by its ID
	// Locate the feature by its ID
	JSONObject json = newFeatureRep.getJsonObject();
}
 
开发者ID:opengeospatial,项目名称:geopackager,代码行数:7,代码来源:ModifyFeatureResource.java

示例5: processForm

import org.restlet.ext.json.JsonRepresentation; //导入方法依赖的package包/类
/**
 * Contract:
 * docid optional; 'text' | 'doc-list' required.
 * command: cmd=ping sends back a simple response
 * 
 * text = UTF-8 encoded text
 * docid = user's provided document ID
 * doc-list = An array of text
 * 
 * cmd=ping = report status.
 * 
 * Where json-array contains { docs=[ {docid='A', text='...'}, {docid='B', text='...',...] }
 * The entire array must be parsable in memory as a single, traversible JSON object.
 * We make no assumption about one-JSON object per line or anything about line-endings as separators.
 * 
 *
 * @param params
 *            the params
 * @return the representation
 * @throws JSONException
 *             the JSON exception
 */
@Post("application/json;charset=utf-8")
public Representation processForm(JsonRepresentation params) throws JSONException {
    org.json.JSONObject json = params.getJsonObject();
    String input = json.optString("text", null);
    String docid = json.optString("docid", null);

    if (input != null) {
        String lang = json.optString("lang", null);
        TextInput item = new TextInput(docid, input);
        item.langid = lang;

        RequestParameters job = fromRequest(json);
        return process(item, job);
    }

    // org.json.JSONArray array = json.optJSONArray("doc-list");
    // if (array != null) {
    // return processList(array);
    // }
    return status("FAIL", "Invalid API use text+docid pair or doc-list was not found");
}
 
开发者ID:OpenSextant,项目名称:Xponents,代码行数:44,代码来源:TaggerResource.java


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