json-viewer icon indicating copy to clipboard operation
json-viewer copied to clipboard

Top level array element

Open thefatoneinthecorner opened this issue 10 years ago • 2 comments

Hi,

It appears that JSON viewer ignores JSON where the top level is an array. Is this correct?

-- Alastair

thefatoneinthecorner avatar Nov 25 '16 14:11 thefatoneinthecorner

Hi @thefatoneinthecorner, sorry for the delay. It should work, I have a test file for it and it is working:

screen shot 2016-11-29 at 09 35 48

Can you check this URL: https://raw.githubusercontent.com/tulios/json-viewer/master/tests/test.array.json

It might be that the API you are using are returning text/html as a content-type, json-viewer is not based on content-type but rather if chrome knows how to render the content or not and when it is text/html the browser tries to render it.

tulios avatar Nov 29 '16 08:11 tulios

Hi Túlio,

You are quite correct! And I am delighted - json-viewer is making a big difference for me.

It’s strange because I thought I did everything right regarding restarting Chrome, setting the content-type, but it didn’t work. I then changed the top level element from an array to an object and it started working. I did some research and apparently, strictly speaking, the json top level element should be an object. I assumed that was the problem ...

Anyway, it all works now and I am very happy. Thanks for your help and a great piece of code!

— Alastair

On 29 Nov 2016, at 08:38, Túlio Ornelas [email protected] wrote:

Hi @thefatoneinthecorner https://github.com/thefatoneinthecorner, sorry for the delay. It should work, I have a test file for it and it is working:

https://cloud.githubusercontent.com/assets/33231/20702240/4b2c6bee-b617-11e6-9a48-41766f449ef9.png Can you check this URL: https://raw.githubusercontent.com/tulios/json-viewer/master/tests/test.array.json https://raw.githubusercontent.com/tulios/json-viewer/master/tests/test.array.json It might be that the API you are using are returning text/html as a content-type, json-viewer is not based on content-type but rather if chrome knows how to render the content or not and when it is text/html the browser tries to render it.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tulios/json-viewer/issues/119#issuecomment-263508752, or mute the thread https://github.com/notifications/unsubscribe-auth/AM_914JZZRBgyRgoebvdzcQ5b9lmBmw6ks5rC-RygaJpZM4K8fdn.

thefatoneinthecorner avatar Nov 29 '16 10:11 thefatoneinthecorner