Open pihao opened 7 years ago
Yes, I am facing the same error. not working most of the time. Sometimes it is working. It was not working since last evening.
This is an issue with Zhanqi.tv - they are responding with a text/html
content type rather than application/json
or text/json
.
@nikrolls You're right! Zhanqi.tv has a bad responding.
As an user, It's better if json-formatter
compatible with this case.
For example, Check if the response content is a valid JSON string when Content-Type is text/html
.
JSON Formatter currently looks for a body
that contains only a pre
element (which is how application/json
documents are presented). To handle this case it would have to also look for a body
that contains only a text node that also parses as valid JSON. This is probably not too computationally intensive because opening plain text documents is a rare case and if it's not JSON the parser will bail pretty quickly.
@pihao, do you have popup blocker or any kind of extensions? I found pop-up blocker inserts a node which let JSON formatter in an indecision. I had given a pull request regarding this, he refused to merge.
@ssi-anik, while that may be an issue it's not in this case.
@ssi-anik I don't have anything to pop up. In short, json-formatter
failed, JSON Viewer and JSONView is OK.
@pihao, @nikrolls I tried to debug the extension and found that Popup blocker puts a tag on the page, and deletes immediately. I tried to disable all the extensions I have and found popoup blocker causes this issue. Pihao, try disabling all the extensions you have and then check if it occurs again or not.
@ssi-anik Still the same.
@ssi-anik, as I mentioned above, zhanqi.tv is delivering the page as text/html
and not */json
:
HTTP/1.1 200 OK
Date: Thu, 27 Apr 2017 02:48:51 GMT
Server: Tengine/2.1.2
→ Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
X-Powered-By: PHP/5.5.25
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST,GET
Access-Control-Allow-Headers: x-requested-with,content-type
CacheType: source-nx
websource: webapp50
Expires: Thu, 27 Apr 2017 02:50:31 GMT
Cache-Control: max-age=100
websource: backupGF_upstream01
X-Via: 1.1 jszjsx50:6 (Cdn Cache Server V2.0), 1.1 yatu5:10 (Cdn Cache Server V2.0)
Connection: keep-alive
Strict-Transport-Security: max-age=31536000;includeSubdomains
When the browser is delivered this content type, it does not wrap the content in a pre
tag like it does when delivered a */json
type. JSON Formatter looks for a solo pre
tag before activating.
Yes, the pop-up blockers interfere with this 'solo pre
tag' rule as well. But that's definitely not the issue here.
@ssi-anik, @nikrolls is right. The tag is the mechanism of Content-Type.
At last, I hope json-formatter could compatible with this situation.
My fork of JSON Formatter now supports this in its latest update, which is currently publishing to the Chrome and Edge stores.
https://www.zhanqi.tv/api/static/v2.1/live/list/20/1.json
JSON Formatter
JSONView