Commit 5c36f7f5 authored by neo's avatar neo

dev replate gson parase jsonstr

parent 7665e2f0
...@@ -337,6 +337,13 @@ ...@@ -337,6 +337,13 @@
<artifactId>spring-data-commons</artifactId> <artifactId>spring-data-commons</artifactId>
<version>2.1.0.RELEASE</version> <version>2.1.0.RELEASE</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
</dependencies> </dependencies>
<profiles> <profiles>
......
package pwc.taxtech.atms.vat.service.impl; package pwc.taxtech.atms.vat.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.google.gson.Gson;
import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
...@@ -51,8 +51,9 @@ public class InputInvoiceDataImportServiceImpl extends VatAbstractService { ...@@ -51,8 +51,9 @@ public class InputInvoiceDataImportServiceImpl extends VatAbstractService {
HttpGet httpget = new HttpGet("http://localhost:8089/input_invoices?page=" + page + "&size=" + size HttpGet httpget = new HttpGet("http://localhost:8089/input_invoices?page=" + page + "&size=" + size
+ "&code=" + code + "&period=" + period); + "&code=" + code + "&period=" + period);
try (CloseableHttpResponse response = httpclient.execute(httpget)) { try (CloseableHttpResponse response = httpclient.execute(httpget)) {
pageInput = JSONObject.parseObject(EntityUtils.toString(response.getEntity()), new TypeReference<Page<InputInvoice>>() { String inputStr = EntityUtils.toString(response.getEntity());
}); pageInput = new Gson().fromJson(inputStr, new TypeReference<Page<InputInvoice>>() {
}.getType());
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment