callumlocke / json-formatter

Makes JSON easy to read.
https://chrome.google.com/webstore/detail/json-formatter/bcjindcccaagfpapjjmafapmmgkkhgoa?hl=en
BSD 3-Clause "New" or "Revised" License
3.77k stars 861 forks source link

Blob URLs #206

Open evandroamparo opened 2 years ago

evandroamparo commented 2 years ago

I'm working on an application that generates blob URLs like this:

blob:https://domain.com/path

The blos are json data containing responses from APIs.

When I click on the extension icon I see this:

image

Not sure if it's possible but it would be nice if I you could make formatting work for blobs too.

harisrahman commented 10 months ago

@callumlocke can you please confirm that this extension does not work for blob URLs ?

evandroamparo commented 10 months ago

It's been a long time. I don't work on that application anymore but I can try to reproduce the issue when I have some time.

callumlocke commented 8 months ago

I'm pretty sure this isn't possible, sorry.

But I'm curious, can you give me more of an example of how you might expect this to work? Is there a way that you can currently display a blob URL containing JSON in a browser tab, unformatted? I might be misunderstanding something.

AmdJonPugh commented 6 months ago

But I'm curious, can you give me more of an example of how you might expect this to work? Is there a way that you can currently display a blob URL containing JSON in a browser tab, unformatted? I might be misunderstanding something.

Hi @callumlocke. You can create a json blob like this:

const obj = { hello: "world" };
const blob = new Blob([JSON.stringify(obj, null, 2)], {
  type: "application/json",
});

Then open the blob in a new tab:

const url = URL.createObjectURL(blob);
window.open(url, '_blank');

The content-type header of the response is correct, so I'd expect the extension to format it:

image

evandroamparo commented 6 months ago

Thank you for the example @AmdJonPugh. When I created this issue in 2022 it was something I used to see almost every day. Maybe it's not possible to format blob URLs due to browsers' limitations but it could help other developers.