本文整理汇总了Java中net.minidev.json.JSONObject.getAsString方法的典型用法代码示例。如果您正苦于以下问题:Java JSONObject.getAsString方法的具体用法?Java JSONObject.getAsString怎么用?Java JSONObject.getAsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minidev.json.JSONObject
的用法示例。
在下文中一共展示了JSONObject.getAsString方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleGet
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
public void handleGet(HttpServletRequest request, HttpServletResponse response, ITicket credentials, JSONObject jsonObject) throws ServletException, IOException {
JSONObject returnMessage = newJSONObject();
String message = "", rtoken="";
String verb = getVerb(jsonObject);
String userId = jsonObject.getAsString(IRPGMicroformat.MEMBER_ID);
String guildLoc = jsonObject.getAsString(IRPGMicroformat.GUILD_LOCATOR);
int code = 0;
IResult r;
System.out.println("RPGHandler.handleGet "+verb);
//AT PRESENT, NO GET Verbs
// if (verb.equals(IUserMicroformat.LIST_USERS)) {
//TODO
// } else {
String x = IErrorMessages.BAD_VERB+"-RPGServletGet-"+verb;
environment.logError(x, null);
throw new ServletException(x);
// }
// returnMessage.put(ICredentialsMicroformat.RESP_TOKEN, rtoken);
// returnMessage.put(ICredentialsMicroformat.RESP_MESSAGE, message);
// super.sendJSON(returnMessage.toJSONString(), code, response);
// returnMessage = null;
}
示例2: getVerb
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
public String getVerb(JSONObject jsonObject) {
String result = "EmptyVerb"; //DEFAULT
String x = jsonObject.getAsString(ICredentialsMicroformat.VERB);
if (x != null)
result = x.trim();
return result;
}
示例3: newSubclassNode
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@Override
public IResult newSubclassNode(JSONObject theTopicShell, ITicket credentials) {
String locator = theTopicShell.getAsString(ITopicMapMicroformat.TOPIC_LOCATOR);
String superClassLocator = theTopicShell.getAsString(ITopicMapMicroformat.SUPERTYPE_LOCATOR);
String lang = theTopicShell.getAsString(ITopicMapMicroformat.LANGUAGE);
String userId = theTopicShell.getAsString(ITQCoreOntology.CREATOR_ID_PROPERTY);
String label = theTopicShell.getAsString(ITopicMapMicroformat.TOPIC_LABEL);
String description = theTopicShell.getAsString(ITopicMapMicroformat.TOPIC_DETAILS);
String smallImagePath = theTopicShell.getAsString(ITopicMapMicroformat.SMALL_IMAGE_PATh);
String largeImagePath = theTopicShell.getAsString(ITopicMapMicroformat.LARGE_IMAGE_PATH);
String isp = theTopicShell.getAsString(ITopicMapMicroformat.IS_PRIVATE);
boolean isPrivate = false;
IResult r;
if (isp.equalsIgnoreCase("t"))
isPrivate = true;
ISubjectProxy n = null;
if (locator != null) {
//First, see if this exists
r = topicMap.getNode(locator, systemCredentials);
if (r.getResultObject() != null)
return r;
n = nodeModel.newSubclassNode(locator, superClassLocator, label, description, lang, userId, smallImagePath, largeImagePath, isPrivate);
} else
n = nodeModel.newSubclassNode(superClassLocator, label, description, lang, userId, smallImagePath, largeImagePath, isPrivate);
IResult result = topicMap.putNode(n);
result.setResultObject(n.getData());
r = relateNodeToUser(n, userId, credentials);
if (r.hasError())
result.addErrorString(r.getErrorString());
return result;
}
示例4: addFeaturesToNode
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
@Override
public IResult addFeaturesToNode(JSONObject cargo, ITicket credentials) {
String lox = cargo.getAsString(ITopicMapMicroformat.TOPIC_LOCATOR);
String userId = cargo.getAsString(ITQCoreOntology.CREATOR_ID_PROPERTY);
IResult r = topicMap.getNode(lox, credentials);
IResult result = new ResultPojo();
if (r.hasError())
result.addErrorString(r.getErrorString());
ISubjectProxy n = (ISubjectProxy)r.getResultObject();
boolean isChanged = false;
if (n != null) {
Iterator<String> itr = cargo.keySet().iterator();
String key;
while (itr.hasNext()) {
key = itr.next();
if (!key.equals(ITopicMapMicroformat.TOPIC_LOCATOR) &&
!key.equals(ITQCoreOntology.CREATOR_ID_PROPERTY)) {
if (key.equals(ITQCoreOntology.RESOURCE_URL_PROPERTY)) {
isChanged = true;
n.setURL(cargo.getAsString(ITQCoreOntology.RESOURCE_URL_PROPERTY));
}
}
}
n.doUpdate();
result = topicMap.updateNode(n, true);
//Pay attention to OptimisticLock
} else {
result.addErrorString("Missing Node "+lox);
}
return result;
}
示例5: readLoginIdentity
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
private String readLoginIdentity(String token) {
try {
JWSObject jwsObject = JWSObject.parse(token);
JSONObject json = jwsObject.getPayload().toJSONObject();
if (!json.containsKey("extraData")) {
return null;
}
return json.getAsString("extraData");
} catch (ParseException ex) {
return null;
}
}
示例6: processRequest
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
/**
* The game here is to return two objects: {@link ITicket} and {@link JSONObject}
* @param request
* @return
* @throws ServletException
*/
private IResult processRequest(HttpServletRequest request) throws ServletException {
IResult result = new ResultPojo();
ITicket t = guestCredentials; //default
String pt = getPath(request);
//seeing things like auth/{....}
System.out.println("PR "+pt);
//PR {"verb":"PutTopic","uIP":"173.164.129.250","uName":"jackpark","cargo":{"uName
//":"jackpark","Lang":"en","Label":"My test topic","Details":"Created to test the
//AngularApp code","LiP":"/images/cogwheel.png","SiP":"/images/cogwheel.sm.png","I
//sPvt":"F","SType":"ClassType"}}
if (!pt.startsWith("{")) {
int where = pt.indexOf('/');
if (where > -1) {
pt = pt.substring(where+1);
}
}
JSONObject jo = jsonFromString(pt);
result.setResultObjectA(jo);
String x = jo.getAsString(ICredentialsMicroformat.USER_IP);
System.out.println("GET IP "+x);
//IP is the user's ip address -- it can be null
String verb = getVerb(jo);
if (!verb.equals(IAuthMicroformat.AUTHENTICATE)) {
//IF THIS IS NOT AN AUTHENTICATE: look up this user
String token = jo.getAsString(ICredentialsMicroformat.SESSION_TOKEN);
// can send in either null, or an empty string
if (token != null && !token.equals("")) {
t = credentialCache.getTicket(token);
if (t == null) {
x = IErrorMessages.TOKEN_NO_USER+token;
//CASE: someone sent in a token, but we don't know who it is: big error
// could be that the same platform logged out before
environment.logError(x, null);
//This can happen if the server goes down, then is
//restarted followed by someone logging out.
//We will not toss an exception anymore.
//throw new ServletException(x);
}
}
//otherwise, there is no token on this transaction
}
result.setResultObject(t);
return result;
}
示例7: getUserRole
import net.minidev.json.JSONObject; //导入方法依赖的package包/类
String getUserRole(JSONObject jsonObject) {
return jsonObject.getAsString(IUserMicroformat.USER_ROLE);
}