本文整理匯總了Java中com.alibaba.fastjson.JSONArray.getString方法的典型用法代碼示例。如果您正苦於以下問題:Java JSONArray.getString方法的具體用法?Java JSONArray.getString怎麽用?Java JSONArray.getString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.alibaba.fastjson.JSONArray
的用法示例。
在下文中一共展示了JSONArray.getString方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: parseZhihuTopics1
import com.alibaba.fastjson.JSONArray; //導入方法依賴的package包/類
public static void parseZhihuTopics1(Page page, Result result) {
String json = page.getContent();
JSONObject object = JSON.parseObject(json);
JSONArray array = object.getJSONArray("msg");
if(array.size()==0) {
result.setSkip(true);
return;
}
for (int i = 0; i < array.size(); i++) {
String topicStr = array.getString(i);
Document doc = Jsoup.parseBodyFragment(topicStr);
Element a = doc.body().select("div.item").first().select("a[target]").first();
String href = "https://www.zhihu.com" + a.attr("href")+"/newest";
result.addRequest(new Request(href, HttpMethod.GET));
}
Request request = new Request("https://www.zhihu.com/node/TopicsPlazzaListV2", HttpMethod.POST);
JSONObject object1 = new JSONObject();
object1.put("topic_id", page.getRequest().getAddch("topic_id"));
object1.put("offset", Integer.valueOf(((Integer) page.getRequest().getAddch("offset")) + 20));
object1.put("hash_id", "22e50cd21ed9df7085ff76d62175e986");
request.addParame("method", "next")
.addParame("params", object1.toJSONString()).addAttach("offset", Integer.valueOf(((Integer) page.getRequest().getAddch("offset")) + 20)).addAttach("topic_id", page.getRequest().getAddch("topic_id"));
result.addRequest(request);
}
示例2: messageDecode
import com.alibaba.fastjson.JSONArray; //導入方法依賴的package包/類
void messageDecode(final ClusterWS socket, String message){
JSONArray jsonArray = JSON.parseObject(message).getJSONArray("#");
switch (jsonArray.getString(0)){
case "p":
//
List<Channel> channelArrayList = socket.getChannels();
String channelName = jsonArray.getString(1);
for (Channel channel :
channelArrayList) {
if (channel.getChannelName().equals(channelName)) {
channel.onMessage(jsonArray.get(2));
break;
}
}
break;
case "e":
socket.getEmitter().emit(jsonArray.getString(1),jsonArray.get(2));
break;
case "s":
if (jsonArray.getString(1).equals("c")){
socket.getPingHandler().getPingTimer().scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
if (socket.getPingHandler().getMissedPing() < 3) {
socket.getPingHandler().incrementMissedPing();
} else {
socket.disconnect(4001, "No pings");
cancel();
}
}
},0,jsonArray.getJSONObject(2).getInteger("ping"));
boolean useBinary = jsonArray.getJSONObject(2).getBoolean("binary");
socket.setUseBinary(useBinary);
if (socket.getClusterWSListener() != null){
socket.getClusterWSListener().onConnected();
}
}
break;
}
}
示例3: skipPermission
import com.alibaba.fastjson.JSONArray; //導入方法依賴的package包/類
public void skipPermission(JSONArray permissionPatterns, int scanningCount) {
UiDevice mDevice = Elements.getGlobal().getmDevice();
// if permission list is empty, avoid execution
if (permissionPatterns.size() == 0) {
return;
}
// regular check for permission scanning
try {
for (int i = 0; i < scanningCount; i++) {
inner:
for (int j = 0; j < permissionPatterns.size(); j++) {
String text = permissionPatterns.getString(j);
UiObject object = mDevice.findObject(new UiSelector().text(text));
if (object.exists()) {
object.click();
break inner;
}
}
Thread.sleep(3000);
}
} catch (Exception e) {
System.out.println(e.getMessage());
System.out.println(e.getCause().toString());
}
}
示例4: get
import com.alibaba.fastjson.JSONArray; //導入方法依賴的package包/類
public static Action get(String actionName,JSONArray args){
switch (actionName) {
case CREATE_BODY:
if (args == null) {
return null;
}
return new CreateBodyAction(args.getJSONObject(0));
case UPDATE_ATTRS:
if (args == null) {
return null;
}
return new UpdateAttributeAction(args.getString(0),args.getJSONObject(1));
case UPDATE_STYLE:
if (args == null) {
return null;
}
return new UpdateStyleAction(args.getString(0),args.getJSONObject(1));
case REMOVE_ELEMENT:
if (args == null) {
return null;
}
return new RemoveElementAction(args.getString(0));
case ADD_ELEMENT:
if (args == null) {
return null;
}
return new AddElementAction(args.getJSONObject(1),args.getString(0),args.getInteger(2));
case MOVE_ELEMENT:
if (args == null) {
return null;
}
return new MoveElementAction(args.getString(0),args.getString(1),args.getInteger(2));
case ADD_EVENT:
if (args == null) {
return null;
}
return new AddEventAction(args.getString(0),args.getString(1));
case REMOVE_EVENT:
if (args == null) {
return null;
}
return new RemoveEventAction(args.getString(0),args.getString(1));
case CREATE_FINISH:
return new CreateFinishAction();
case REFRESH_FINISH:
return new RefreshFinishAction();
case UPDATE_FINISH:
return new UpdateFinishAction();
case SCROLL_TO_ELEMENT:
if (args == null) {
return null;
}
String ref = args.size() >= 1 ? args.getString(0) : null;
JSONObject options = args.size() >= 2 ? args.getJSONObject(1) : null;
return new ScrollToElementAction(ref, options);
case ADD_RULE:
if (args == null) {
return null;
}
return new AddRuleAction(args.getString(0),args.getJSONObject(1));
case GET_COMPONENT_RECT:
if(args == null){
return null;
}
return new GetComponentRectAction(args.getString(0),args.getString(1));
case INVOKE_METHOD:
if(args == null){
return null;
}
return new InvokeMethodAction(args.getString(0),args.getString(1),args.getJSONArray(2));
}
return null;
}
示例5: convert
import com.alibaba.fastjson.JSONArray; //導入方法依賴的package包/類
@Override
public ArrayList<MultipleItemEntity> convert() {
final JSONArray dataArray = JSON.parseObject(getJsonData()).getJSONArray("data");
final int size = dataArray.size();
for (int i = 0; i < size; i++) {
final JSONObject data = dataArray.getJSONObject(i);
final String imageUrl = data.getString("imageUrl");
final String text = data.getString("text");
final int spanSize = data.getInteger("spanSize");
final int id = data.getInteger("goodsId");
final JSONArray banners = data.getJSONArray("banners");
final ArrayList<String> bannerImages = new ArrayList<>();
int type = 0;
if (imageUrl == null && text != null) {
type = ItemType.TEXT;
} else if (imageUrl != null && text == null) {
type = ItemType.IMAGE;
} else if (imageUrl != null) {
type = ItemType.TEXT_IMAGE;
} else if (banners != null) {
type = ItemType.BANNER;
//Banner的初始化
final int bannerSize = banners.size();
for (int j = 0; j < bannerSize; j++) {
final String banner = banners.getString(j);
bannerImages.add(banner);
}
}
final MultipleItemEntity entity = MultipleItemEntity.builder()
.setField(MultipleFields.ITEM_TYPE,type)
.setField(MultipleFields.SPAN_SIZE,spanSize)
.setField(MultipleFields.ID,id)
.setField(MultipleFields.TEXT,text)
.setField(MultipleFields.IMAGE_URL,imageUrl)
.setField(MultipleFields.BANNERS,bannerImages)
.build();
ENTITIES.add(entity);
}
return ENTITIES;
}