From b62b0e0f2e6836b716b23bebe250345d74b5eb98 Mon Sep 17 00:00:00 2001 From: snoop Date: Wed, 17 May 2017 14:10:47 +0900 Subject: [PATCH] fix process --- .../com/loafle/overflow/crawler/Crawler.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/loafle/overflow/crawler/Crawler.java b/src/main/java/com/loafle/overflow/crawler/Crawler.java index b4b4184..907b935 100644 --- a/src/main/java/com/loafle/overflow/crawler/Crawler.java +++ b/src/main/java/com/loafle/overflow/crawler/Crawler.java @@ -3,9 +3,11 @@ package com.loafle.overflow.crawler; import com.fasterxml.jackson.databind.ObjectMapper; import com.loafle.overflow.crawler.config.Config; +import com.loafle.overflow.crawler.result.OFResultSet; import java.io.File; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -32,7 +34,21 @@ public abstract class Crawler { return true; } public Object get(String id) throws Exception { - return getInternal(getConfig(id)); + + List rsList = (List)getInternal(getConfig(id)); + + Map rm = new HashMap<>(); + Map m = null; + for (OFResultSet rs : rsList) { + m = rs.getData(); + rm.putAll(m); + } + + ObjectMapper mapper = new ObjectMapper(); + + String json = mapper.writeValueAsString(rm); + + return json.getBytes(); } public Object init(byte [] data) throws Exception { add(data);