javajsonparser_JavaJSONParser.parse⽅法代碼⽰例
本⽂整理匯總了Java中org.json.simple.parser.JSONParser.parse⽅法的典型⽤法代碼⽰例。如果您正苦於以下問題:Java JSONParser.parse⽅法的具體⽤法?Java JSONParser.parse怎麽⽤?Java JSONParser.parse使⽤的例⼦?那麽恭喜您, 這裏精選的⽅法代碼⽰例或許可以為您提供幫助。您也可以進⼀步了解該⽅法所在類org.json.simple.parser.JSONParser的⽤法⽰例。
在下⽂中⼀共展⽰了JSONParser.parse⽅法的19個代碼⽰例,這些例⼦默認根據受歡迎程度排序。您可以為喜歡或者感覺有⽤的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼⽰例。
⽰例1: getAP
點讚 3
import org.json.simple.parser.JSONParser; //導⼊⽅法依賴的package包/類
public String getAP(String json) throws ParseException {
long apAmount = -1;
if (json != null) {
JSONParser parser = new JSONParser();
JSONObject battleNetCharacter = (JSONObject) parser.parse(json);
JSONObject achivements = (JSONObject) ("achievements");
JSONArray criteriaObject = (JSONArray) ("criteria");
int criteriaNumber = -1;
for (int i = 0; i < criteriaObject.size(); i++) {
if (((i) == 30103) {
criteriaNumber = i;
}
}
error parse newif (criteriaNumber != -1) {
apAmount = (long) ((("criteriaQuantity")).get(criteriaNumber);
}
}
String result = null;
if (apAmount != -1) {
result = format(apAmount);
}
return result;
}
開發者ID:greatman,項⽬名稱:legendarybot,代碼⾏數:26,
⽰例2: getJodelShareLink
/
**
* Get share url
* @param postID ID of the post to share
* @return The requestResponse of type JodelRequestResponse
*/
public JodelRequestResponse getJodelShareLink(String postID) { JodelRequestResponse requestResponse = new JodelRequestResponse();
this.updateHTTPParameter();
JodelHTTPResponse getShareLink = JodelShareURL(postID); requestResponse.httpResponseCode = sponseCode;
if (sponseCode == 200) {
String responseJodelsMessage = sponseMessage; requestResponse.rawResponse
Message = responseJodelsMessage;
JSONParser parser = new JSONParser();
try {
JSONObject responseJson = (JSONObject) parser.parse(responseJodelsMessage); String url = (String) ("url");
} catch (Exception e) {
requestResponse.rawErrorMessage = e.getMessage();
e.printStackTrace();
< = true;
}
} else {
< = true;
}
return requestResponse;
}
開發者ID:fr31b3u73r,項⽬名稱:JodelAPI,代碼⾏數:30,
⽰例3: refreshAccessToken
/**
* Refreshes the Access Token of the currently used account
*/
public void refreshAccessToken() {
this.updateHTTPParameter();
JodelHTTPResponse requestResponse = NewAccessToken(); if (sponseCode == 200) {
String responseMessage = sponseMessage;
JSONParser parser = new JSONParser();
try {
JSONObject responseJson = (JSONObject) parser.parse(responseMessage); this.accessToken = ("access_token").toString();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
開發者ID:fr31b3u73r,項⽬名稱:JodelAPI,代碼⾏數:20,
⽰例4: getAclEntries
點讚 2
import org.json.simple.parser.JSONParser; //導⼊⽅法依賴的package包/類
/**
* Given the JSON output from the GETACLSTATUS call, return the
* 'entries' value as a List.
* @param statusJson JSON from GETACLSTATUS
* @return A List of Strings which are the elements of the ACL entries
* @throws Exception
*/
private List getAclEntries ( String statusJson ) throws Exception {
List entries = new ArrayList();
JSONParser parser = new JSONParser();
JSONObject jsonObject = (JSONObject) parser.parse(statusJson); JSONObject details = (JSONObject) ("AclStatus");
JSONArray jsonEntries = (JSONArray) ("entries");
if ( jsonEntries != null ) {
for (Object e : jsonEntries) {
entries.String());
}
}
return entries;
}
開發者ID:naver,項⽬名稱:hadoop,代碼⾏數:21,
⽰例5: testHandleAttributeRemoved
點讚 2
import org.json.simple.parser.JSONParser; //導⼊⽅法依賴的package包/類
/**
* Test of {@code handleAttributeRemoved} method.
*/
@Test
public void testHandleAttributeRemoved() throws ParseException { TransportImplementation transport = new DummyTransportImplementation(); DOM dom = new DOM(new TransportHelper(transport), null);
final Node root = Document();
final String ATTR_NAME = "class"; // NOI18N
final int[] eventsFired = new int[1];
DOM.Listener listener = new DOMAdapter() {
@Override
public void attributeRemoved(Node node, String attrName) {
eventsFired[0]++;
assertEquals(ATTR_NAME, attrName);
assertEquals(root, node);
Node.Attribute attr = Attribute(attrName);
assertNull(attr);
}
};
dom.addListener(listener);
JSONParser parser = new JSONParser();
// Modification of a known node
Object json = parser.parse("{\"nodeId\":" + ROOT_NODE_ID + ",\"name\":\"" + ATTR_NAME + "\"}"); // NOI18N dom.handleAttributeRemoved((JSONObject)json);
assertEquals(1, eventsFired[0]);
// Modification of an unknown node
json = parser.parse("{\"nodeId\":" + (ROOT_NODE_ID+1) + ",\"name\":\"someName\"}"); // NOI18N
dom.handleAttributeRemoved((JSONObject)json);
assertEquals(1, eventsFired[0]);
}
開發者ID:apache,項⽬名稱:incubator-netbeans,代碼⾏數:34,
⽰例6: convertToItem
點讚 2
import org.json.simple.parser.JSONParser; //導⼊⽅法依賴的package包/類
@SuppressWarnings("unchecked")
private static T convertToItem(String item, Class clazz) throws ParseException {
if (clazz == JSONObject.class || clazz == Map.class) {
/
/ JSON部分のみを取り出す。
int jsonStart = item.indexOf("{");
String json = "{}";
if (-1 < jsonStart) {
json = item.substring(jsonStart);
JSONParser parser = new JSONParser();
return (T) parser.parse(json);
}
}
return (T) item;
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。