检查一组URL,如果它包含特定的表ID(check a set of URLs if it contains a particular table ID)
我有一组URL链接,一些包含表,一些不返回任何表。 我检查了源代码,并且在运行时加载了这个特定的表ID。 是否有脚本或工具来检查每个URL内容并查看它是否包含该特定表ID并返回true。
我可以使用此脚本或工具加载一批URL,以查看哪个url包含我要查找的表。
谢谢! 哈龙
I have a set of URL links , some which contains table and some that does not return any table. I've inspected the source and there is this particular table ID that loads at runtime. Is there a script or tool to check each url content and see if it contains that particular table ID and return true.
I can use this script or tool to load a batch of URL's to see which url contains the table that I am looking for.
Thanks! Haroon
原文:
最满意答案
看起来您的数据结构正在映射到数组,而不是映射。 我对此感到有些惊讶,因为你的第一个索引是1(不是0)。 但错误信息非常清楚它正在尝试做什么。
因此,要解决此问题,请将房间映射到
List
或数组:private List<FirebaseRoomReference> rooms;
为防止此类问题, 强烈建议不要使用数字索引。 使用
push()
生成的值或使用固定字符串为数字添加前缀,这样就不会混淆它的类型:room_1
,room_2
等。更新
我可以用这个读取你更新的JSON:
public static class FirebaseRoomReference { private String id; private String name; private String ownerName; public String getId() { return id; } public String getName() { return name; } public String getOwnerName() { return ownerName; } } public static class FirebaseSchool { private String id; private String name; private String address; private String city; //private List<FirebaseUserReference> admins; private Map<String, FirebaseRoomReference> rooms; //public List<FirebaseUserReference> getAdmins() { return admins; } public Map<String, FirebaseRoomReference> getRooms() { return rooms; } public String getId() { return id; } public String getName() { return name; } public String getAddress() { return address; } public String getCity() { return city; } } public static void main(String[] args) throws Exception { Firebase ref = new Firebase("https://stackoverflow.firebaseio.com/35109413"); ref.child("schools").addChildEventListener(new ChildEventListener() { @Override public void onChildAdded(DataSnapshot snapshot, String s) { System.out.println(snapshot.getValue(FirebaseSchool.class)); } });
我改变的事情:
- 我将POJO类标记为静态,因为我将它们作为内部类包含在我的测试程序中。
- 我删除了用户管理员,因为它们不在您的JSON中
- 我将List更改为Map,因为您现在使用的是字符串键
在我更改最后一点之前,我收到了您所做的相同错误消息。
It looks like your data structure is being mapped to an array, not a map. I'm somewhat surprised about that, since your first index is 1 (not 0). But the error message is pretty explicit about what it's trying to do.
So to solve the problem, map the rooms to an
List
or array:private List<FirebaseRoomReference> rooms;
To prevent this type of problem it is highly recommended to not use numeric indexes. Either use the values generated by
push()
or prefix your numbers with a fixed string, so that there's never any confusion about what type it is:room_1
,room_2
, etc.Update
I can read your updated JSON with this:
public static class FirebaseRoomReference { private String id; private String name; private String ownerName; public String getId() { return id; } public String getName() { return name; } public String getOwnerName() { return ownerName; } } public static class FirebaseSchool { private String id; private String name; private String address; private String city; //private List<FirebaseUserReference> admins; private Map<String, FirebaseRoomReference> rooms; //public List<FirebaseUserReference> getAdmins() { return admins; } public Map<String, FirebaseRoomReference> getRooms() { return rooms; } public String getId() { return id; } public String getName() { return name; } public String getAddress() { return address; } public String getCity() { return city; } } public static void main(String[] args) throws Exception { Firebase ref = new Firebase("https://stackoverflow.firebaseio.com/35109413"); ref.child("schools").addChildEventListener(new ChildEventListener() { @Override public void onChildAdded(DataSnapshot snapshot, String s) { System.out.println(snapshot.getValue(FirebaseSchool.class)); } });
Things I changed:
- I marked the POJO classes as static, since I include them as inner classes in my test program.
- I removed the user admins, since they're not present in your JSON
- I changed your List to a Map, since you're now using string keys
Before I change that last point, I got the same error message you did.
相关问答
更多-
您的JSON字符串格式错误: center的类型是无效对象的数组。 用longitude和latitude的JSON字符串中的{和}替换[和] ,使它们成为对象: [ { "name" : "New York", "number" : "732921", "center" : { "latitude" : 38.895111, "longitude" : -77.036667 ...
-
我找到了一个使用以下线程作为参考的解决方案: Jackson:忽略属性而不是抛出JsonMappingException 我写了一个自定义反序列化器并用它来忽略错误。 public class CustomListingDeserializer extends JsonDeserializer
-
你没有向我们展示JsonGen课程。 如果要反序列化的json文件是JsonGen类型的对象数组,那么您需要这样做: List
jsongen = objmapper.readValue(jsonUrl, new TypeReference - >() {});
for(JsonGen element : jsongen) {
System.out.println(element.getName())
}
You didn't show us Js ...
-
你的json包含一个数组,但你试图将它解析成对象。 出现此错误是因为对象必须从{ 。 你有两个选择: 您可以摆脱ShopContainer类,并改用Shop[] ShopContainer response = restTemplate.getForObject( url, ShopContainer.class); 用。。。来代替 Shop[] response = restTemplate.getForObject(url, Shop[].class); 然后使对象形成或任何你需要的。 ...
-
您不需要PublisheDataList中间类来反序列化到Collection,尝试直接使用mapper反序列化 List
publisheDataList = mapper.convertValue(json, mapper.getTypeFactory().constructCollectionType(List.class, PublisheData.class)); You do not need a PublisheDataList intermediate clas ... -
杰克逊显然无法将传入的JSON反序列化为Integer 。 如果您坚持要通过请求主体发送用户的JSON表示,则应该将userId封装在另一个bean中,如下所示: public class User { private Integer userId; // getters and setters } 然后使用该bean作为处理方法参数: @RequestMapping(...) public @ResponseBody Record getRecord(@RequestBody User ...
-
创建一个简单的pojo Class First class MyClass { @JsonProperty private String Name; @JsonProperty private String CreationDate; } 并使用此代码... byte[] mapData = Files.readAllBytes(Paths.get("process.txt")); ObjectMapper objectMapper=new ObjectMapper(); //add this line ...
-
无法从START_ARRAY标记中反序列化对象的实例(Can not deserialize instance of object out of START_ARRAY token)[2023-09-14]
我的客户端JSON输出是以包含一个用户和我更改服务器注册方法的用户列表的形式来解决我的问题: @RequestMapping(value = "/register",method = RequestMethod.POST) @ResponseBody public boolean registerNewUser(@RequestBody Listusers){ if(users!=null){ try { SessionFactory sessi ... -
在MyModel类中进行以下更改 public class MyModel { public MyModel() {} private int total; private List
rows; public int getTotal() { return total; } public List getRows() { return rows; } } Made below changes in your MyMod ... -
看起来您的数据结构正在映射到数组,而不是映射。 我对此感到有些惊讶,因为你的第一个索引是1(不是0)。 但错误信息非常清楚它正在尝试做什么。 因此,要解决此问题,请将房间映射到List或数组: private List
rooms; 为防止此类问题, 强烈建议不要使用数字索引。 使用push()生成的值或使用固定字符串为数字添加前缀,这样就不会混淆它的类型: room_1 , room_2等。 更新 我可以用这个读取你更新的JSON: public stati ...