java.io.EOFException 用 clojure Transit 解析 JSON 时
java.io.EOFException when parsing JSON with clojure Transit
我正在使用 (t/read request-body :json)
从输入流中读取
我得到一个 java.lang.RuntimeException: java.io.EOFException
.
{"A":"B", "C":"D"}
java.lang.RuntimeException: java.io.EOFException
ReaderFactory.java:122 com.cognitect.transit.impl.ReaderFactory$ReaderImpl.read
TransitFactory.java:136 com.cognitect.transit.TransitFactory$DeferredJsonReader.read
transit.clj:285 cognitect.transit/read
知道为什么会这样吗?
为清楚起见,curl POST 请求:
%curl -X POST ...../word -H "Content-Type: application/json" -d '{"A":"B", "C":"D"}' -v > abc.html
* Hostname was NOT found in DNS cache
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 178.63.65.149...
* Connected to ..... (178.63.65.149) port 80 (#0)
> POST /word HTTP/1.1
> User-Agent: curl/7.37.1
> Host: .....
> Accept: */*
> Content-Type: application/json
> Content-Length: 18
>
} [data not shown]
* upload completely sent off: 18 out of 18 bytes
< HTTP/1.1 500 Server Error
* Server nginx/1.2.1 is not blacklisted
< Server: nginx/1.2.1
< Date: Sat, 04 Apr 2015 19:05:03 GMT
< Content-Type: text/html;charset=ISO-8859-1
< Content-Length: 13190
< Connection: keep-alive
<
{ [data not shown]
100 13208 100 13190 100 18 79062 107 --:--:-- --:--:-- --:--:-- 79457
* Connection #0 to host ..... left intact
查看您的日志记录数据,您的请求正文实际上并不是 json,它看起来像是一个 multi-part/form-data 编码形式,其中包含一个 json 文件上传。
我正在使用 (t/read request-body :json)
从输入流中读取
我得到一个 java.lang.RuntimeException: java.io.EOFException
.
{"A":"B", "C":"D"} java.lang.RuntimeException: java.io.EOFException ReaderFactory.java:122 com.cognitect.transit.impl.ReaderFactory$ReaderImpl.read TransitFactory.java:136 com.cognitect.transit.TransitFactory$DeferredJsonReader.read transit.clj:285 cognitect.transit/read
知道为什么会这样吗?
为清楚起见,curl POST 请求:
%curl -X POST ...../word -H "Content-Type: application/json" -d '{"A":"B", "C":"D"}' -v > abc.html
* Hostname was NOT found in DNS cache
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 178.63.65.149...
* Connected to ..... (178.63.65.149) port 80 (#0)
> POST /word HTTP/1.1
> User-Agent: curl/7.37.1
> Host: .....
> Accept: */*
> Content-Type: application/json
> Content-Length: 18
>
} [data not shown]
* upload completely sent off: 18 out of 18 bytes
< HTTP/1.1 500 Server Error
* Server nginx/1.2.1 is not blacklisted
< Server: nginx/1.2.1
< Date: Sat, 04 Apr 2015 19:05:03 GMT
< Content-Type: text/html;charset=ISO-8859-1
< Content-Length: 13190
< Connection: keep-alive
<
{ [data not shown]
100 13208 100 13190 100 18 79062 107 --:--:-- --:--:-- --:--:-- 79457
* Connection #0 to host ..... left intact
查看您的日志记录数据,您的请求正文实际上并不是 json,它看起来像是一个 multi-part/form-data 编码形式,其中包含一个 json 文件上传。