java - 如何转换列表从 vertx 到 String Array 以用于笛卡尔积
问题描述
我有一个应该从 json 文件访问数据的方法,基本上是一个如下所示的 api,该方法访问了www.my-work.com的 API ,接下来我访问了参数(getConfig 方法返回一个 JsonObject)。
我想做的事?首先,将参数转换为 String [],然后使用 guava 制作笛卡尔积,然后将 String 附加到
String apiUrl = operator.getConfig().getString("api");
我的方法是,
public ParserService runParserTask(String tourOperator, Handler<AsyncResult<Void>> handler) {
TourOperator operator = TourOperatorFactory.getOperator(tourOperator, vertx, config);
String apiUrl = operator.getConfig().getString("api");
operator.getConfig().getJsonArray("parameters").stream().map(o -> {
List<JsonArray> parameters = ((JsonObject)o).getJsonObject("queryParameters").stream().map(e -> {
// TODO int's need to convert JsonArray to String[] and change parameters variable type
return (JsonArray)e.getValue();
}).collect(Collectors.toList());
// TODO further we'll compact all parameters variants (let's use guava cartesian lib,
// TODO do not forget to add guava dependency to maven project) and call operator.fetchData(url)
return null;
});
return null;
}
为了更好地理解下面的 json 文件(已编辑且未完整)
"operators": {
"tez" : {
"api": "www.my-work.com/search/getResult",
"parameters": [
{
"country": "London",
"queryParameters": {
"priceMin": ["0"],
"priceMax":["150000"],
"currency":["5561"],
parameters should scroll at the same time
"hotelClassId":["4"],
"accommodationId":["158525","9002884","1","14317","14357",
"282471","161160"],
"rAndBId":["15350","2424","2474","2749","5737","5738"],
"tourTypes": ["1","2","3","6"],
"locale":["ru"],
"cityId":["786"],
"countryId":["147573"],
解决方案
推荐阅读
- android - “无法访问主线程上的数据库,因为它可能会长时间锁定 UI。” 我的协程错误
- python - ProcessPoolExecutor 创建超过允许的最大工作人员
- spring-boot - 使用规范作为查询从@Entity 以及关系表中获取记录
- javascript - 我可以创建一个在删除输入文本时触发的事件吗?
- python - 如何用另一行的值替换 NaN?
- cassandra - 让 Cassandra 在主键冲突时抛出异常
- ios - 快速获取推送通知 userInfo 并通过它呈现 ViewController
- node.js - 将 CC Avenue 与以 Node js 作为后端的 Ionic 4 应用程序集成。在加密和将数据发布到 InApp 浏览器 web 视图方面需要帮助
- python - 以图片形式阅读 PDF
- c# - 我应该如何使用巨大的表动态存储查询数据?