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


Java JSONArray.getString方法代码示例

本文整理汇总了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);
}
 
开发者ID:StevenKin,项目名称:ZhihuQuestionsSpider,代码行数:25,代码来源:ParseRegularUtil.java

示例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;
    }
}
 
开发者ID:ClusterWS,项目名称:ClusterWS-Client-Java,代码行数:41,代码来源:MessageHandler.java

示例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());
    }
}
 
开发者ID:macacajs,项目名称:UIAutomatorWD,代码行数:29,代码来源:UIAutomatorWD.java

示例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;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:75,代码来源:Actions.java

示例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;
}
 
开发者ID:remerber,项目名称:FastEc,代码行数:47,代码来源:IndexDataConverter.java


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