How to open local JSON file? Topic is solved

Users and developers helping users with generic and technical Pale Moon issues on all operating systems.

Moderator: trava90

Forum rules
This board is for technical/general usage questions and troubleshooting for the Pale Moon browser only.
Technical issues and questions not related to the Pale Moon browser should be posted in other boards!
Please keep off-topic and general discussion out of this board, thank you!
User avatar
Kris_88
Lunatic
Lunatic
Posts: 277
Joined: 2021-01-26, 11:18

Re: How to open local JSON file?

Unread post by Kris_88 » 2022-01-17, 16:24

You should register mime type in Windows.
Then the file type will be properly determined by the browser.

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.json]
"Content Type"="application/json"
I checked, without such registration, Pale Moon really shows raw data when open local file.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 32007
Joined: 2011-08-28, 17:27
Location: Tranås, SE
Contact:

Re: How to open local JSON file?

Unread post by Moonchild » 2022-01-17, 17:27

Ah. I guess that makes sense. It works on my end because the mime type is registered (because of visual studio). Nice catch if that's the case!
"You will observe with concern how long a useful truth may be known and exist before it is generally received and practiced on." -- Benjamin Franklin
"Compromise and collaboration lie at the heart of all great endeavours" -- Kassandra
Image

User avatar
gepus
Astronaut
Astronaut
Posts: 715
Joined: 2017-12-14, 12:59

Re: How to open local JSON file?

Unread post by gepus » 2022-01-17, 17:52

Bingo! :)
Works after registering the mime type.

User avatar
szczelnybez
Hobby Astronomer
Hobby Astronomer
Posts: 18
Joined: 2021-01-20, 00:11

Re: How to open local JSON file?

Unread post by szczelnybez » 2022-01-18, 11:42

Yep,
That works for me as well! Thanks.
The file I used is also now attached as requested:
pmoon2.zip
(251 Bytes) Downloaded 10 times

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 32007
Joined: 2011-08-28, 17:27
Location: Tranås, SE
Contact:

Re: How to open local JSON file?

Unread post by Moonchild » 2022-01-18, 12:06

Thanks but it's clear the problem wasn't with the actual file but rather a system configuration. Sorry for the unnecessary effort!
"You will observe with concern how long a useful truth may be known and exist before it is generally received and practiced on." -- Benjamin Franklin
"Compromise and collaboration lie at the heart of all great endeavours" -- Kassandra
Image

User avatar
szczelnybez
Hobby Astronomer
Hobby Astronomer
Posts: 18
Joined: 2021-01-20, 00:11

Re: How to open local JSON file?

Unread post by szczelnybez » 2022-01-18, 21:33

That's all right.
I use a 7-zip version of PM which now I think might be the root of the problem. Presumably, same would happen with a portable version.
Going forward, can this be resolved for these versions somehow?

User avatar
Kris_88
Lunatic
Lunatic
Posts: 277
Joined: 2021-01-26, 11:18

Re: How to open local JSON file?

Unread post by Kris_88 » 2022-01-19, 06:29

nsExternalHelperAppService.cpp
defaultMimeEntries

There is "json" entry in FF91 defaultMimeEntries table.
FF91:

Code: Select all

static const nsDefaultMimeTypeEntry defaultMimeEntries[] = {
    // The following are those extensions that we're asked about during startup,
    // sorted by order used
    {IMAGE_GIF, "gif"},
    {TEXT_XML, "xml"},
    {APPLICATION_RDF, "rdf"},
    {IMAGE_PNG, "png"},
    // -- end extensions used during startup
    {TEXT_CSS, "css"},
    {IMAGE_JPEG, "jpeg"},
    {IMAGE_JPEG, "jpg"},
    {IMAGE_SVG_XML, "svg"},
    {TEXT_HTML, "html"},
    {TEXT_HTML, "htm"},
    {APPLICATION_XPINSTALL, "xpi"},
    {"application/xhtml+xml", "xhtml"},
    {"application/xhtml+xml", "xht"},
    {TEXT_PLAIN, "txt"},
    {APPLICATION_JSON, "json"},
    {APPLICATION_XJAVASCRIPT, "js"},
    {APPLICATION_XJAVASCRIPT, "jsm"},
    {VIDEO_OGG, "ogv"},
    {VIDEO_OGG, "ogg"},
    {APPLICATION_OGG, "ogg"},
    {AUDIO_OGG, "oga"},
    {AUDIO_OGG, "opus"},
    {APPLICATION_PDF, "pdf"},
    {VIDEO_WEBM, "webm"},
    {AUDIO_WEBM, "webm"},
    {IMAGE_ICO, "ico"},
    {TEXT_PLAIN, "properties"},
    {TEXT_PLAIN, "locale"},
    {TEXT_PLAIN, "ftl"},
#if defined(MOZ_WMF)
    {VIDEO_MP4, "mp4"},
    {AUDIO_MP4, "m4a"},
    {AUDIO_MP3, "mp3"},
#endif
#ifdef MOZ_RAW
    {VIDEO_RAW, "yuv"}
#endif
};
PM:

Code: Select all

static const nsDefaultMimeTypeEntry defaultMimeEntries[] =
{
  // The following are those extensions that we're asked about during startup,
  // sorted by order used
  { IMAGE_GIF, "gif" },
  { TEXT_XML, "xml" },
  { APPLICATION_RDF, "rdf" },
  { TEXT_XUL, "xul" },
  { IMAGE_PNG, "png" },
  // -- end extensions used during startup
  { TEXT_CSS, "css" },
  { IMAGE_JPEG, "jpeg" },
  { IMAGE_JPEG, "jpg" },
  { IMAGE_SVG_XML, "svg" },
  { TEXT_HTML, "html" },
  { TEXT_HTML, "htm" },
  { APPLICATION_XPINSTALL, "xpi" },
  { "application/xhtml+xml", "xhtml" },
  { "application/xhtml+xml", "xht" },
  { TEXT_PLAIN, "txt" },
  { VIDEO_OGG, "ogv" },
  { VIDEO_OGG, "ogg" },
  { APPLICATION_OGG, "ogg" },
  { AUDIO_OGG, "oga" },
  { AUDIO_OGG, "opus" },
  { APPLICATION_PDF, "pdf" },
  { VIDEO_WEBM, "webm" },
  { AUDIO_WEBM, "webm" },
#if defined(MOZ_WMF)
  { VIDEO_MP4, "mp4" },
  { AUDIO_MP4, "m4a" },
  { AUDIO_MP3, "mp3" },
#endif
#ifdef MOZ_RAW
  { VIDEO_RAW, "yuv" }
#endif
};

User avatar
gepus
Astronaut
Astronaut
Posts: 715
Joined: 2017-12-14, 12:59

Re: How to open local JSON file?

Unread post by gepus » 2022-01-19, 12:39

It seems that till FF56 it wasn't added. The change was introduced some time later.
However it explains why it worked for me with one browser but not with the other.

User avatar
Moonchild
Pale Moon guru
Pale Moon guru
Posts: 32007
Joined: 2011-08-28, 17:27
Location: Tranås, SE
Contact:

Re: How to open local JSON file?

Unread post by Moonchild » 2022-01-19, 13:41

I've added these MIME types accordingly to the default extension list for a future release.
"You will observe with concern how long a useful truth may be known and exist before it is generally received and practiced on." -- Benjamin Franklin
"Compromise and collaboration lie at the heart of all great endeavours" -- Kassandra
Image

BenFenner
Lunatic
Lunatic
Posts: 341
Joined: 2015-06-01, 12:52
Location: US Southeast

Re: How to open local JSON file?

Unread post by BenFenner » 2022-01-25, 15:50

Edit 3: Ignore this post. It would seem that the problem is caused by incorrect MIME types in the response headers caused by my fiddling with the Ruby on Rails rendering engine. Or at least that's what I'm telling myself right now. While Pale Moon's behavior could be a bit more predictable, it might all be down to my server-side malarkey. If I do end up finding some true misbehavior in Pale Moon I'll post again.

Edit 4: It seems to be an insane bug in the version of Ruby on Rails I'm using (4.2 at the moment). Modifying a string in place with String#slice! during a render (bodged before_render filter) seems to cause all sorts of unpredictable behavior. Anyone is welcome to delete this post if they wish.


-------------------------------------------------------------------
Pale Moon 29.4.4 (64-bit) on Linux Mint

I've never had any problem with JSON display until today.
I'm also now getting the plaintext JSON rendering instead of the pretty version.
This is for a web API I'm writing, and it's been behaving well all month until now.

Oddly enough, it will work for a bit but then if I send a JSON payload without a MIME type the behavior starts. If I then resume sending the MIME type it does not recover. And once it's in this state if I ask for XML but get JSON back I get an XML Parsing Error: not well-formed error instead of the pretty JSON it would display before (this may be an improvement, just detailing what I am experiencing).

Restarting the browser gets things behaving well for a bit until I access a JSON payload with no MIME type again.

The console shows this error for the JSON:

Code: Select all

The character encoding of the plain text document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the file needs to be declared in the transfer protocol or file needs to use a byte order mark as an encoding signature.
The XML rendering issue shows this error in the console:

Code: Select all

XML Parsing Error: not well-formed
Location: my.api.example.com?param=test
Line Number 1, Column 1:
Screenshot: https://i.imgur.com/fSMPTmg.png


I realize this not an amazing bug report. I will test further and report back. I will also provide any additional info I can.


Edit: Some corrections. Restarting the browser does not help. When one tab shows ugly JSON, another can show pretty JSON, even pretty JSON when XML was asked for (but JSON was returned by the server). So I don't have much to go on, other than I can reproduce the behavior of ugly JSON pretty easily. I just need to narrow down how exactly.

Edit 2: Working with one tab accessing one URL that can produce this issue, refreshing the tab with F5 produces the same ugly JSON. As does pressing [Enter] in the location bar to revisit the URL.
However a hard refresh with Ctrl + F5 gets the pretty JSON back! Absolutely nothing has changed between the refreshes. I'm still experimenting...

Post Reply