MozillaZine


render JSON data prettified?

Discussion of general topics about Seamonkey
Justinh
 
Posts: 336
Joined: November 13th, 2004, 7:03 pm
Location: Alabama

Post Posted June 22nd, 2021, 2:52 pm

Is there a way to make SM render JSON data in the prettified structure? This is when an API call is put in the URL bar.

SM renders as a single-line. Fx renders as a structure.

If there is a way to get this from the dev console, that would be appreciated also.

morat
 
Posts: 4839
Joined: February 3rd, 2009, 6:29 pm

Post Posted June 25th, 2021, 8:57 pm

Try toggling the devtools.jsonview.enabled pref in SeaMonkey.

Test page
http://code.cdn.mozilla.net/devices/devices.json

I can disable the JSON viewer with the devtools.jsonview.enabled pref in Firefox.

JSON viewer
http://developer.mozilla.org/docs/Tools/JSON_viewer

Reference
http://searchfox.org/mozilla-release/source/devtools/client/jsonview

Justinh
 
Posts: 336
Joined: November 13th, 2004, 7:03 pm
Location: Alabama

Post Posted June 26th, 2021, 11:55 am

That pref apparently has no effect in SM.

morat
 
Posts: 4839
Joined: February 3rd, 2009, 6:29 pm

Post Posted June 26th, 2021, 2:15 pm

I can pretty print a JSON page using the Browser Console in SeaMonkey Portable 2.53.7.1.

Menu Bar > Tools > Web Development > Browser Console

Code: Select all
(function () {
  var pre = content.document.createElement("pre");
  var jsonText = content.document.body.innerText;
  var jsonPretty = JSON.stringify(JSON.parse(jsonText), null, 2);
  content.document.body.appendChild(pre).innerHTML = jsonPretty;
})();

Maybe you can use the code snippet with the Custom Buttons or keyconfig or userChromeJS addon.

P.S.

I could not get the JSON viewer code to run in SeaMonkey.

raj_bhaskar

User avatar
 
Posts: 1913
Joined: November 7th, 2002, 3:50 am
Location: Glasgow, Scotland

Post Posted July 15th, 2021, 7:47 am

I still have an old version of JSONView installed. It looks like you can get old versions from Github: https://github.com/bhollis/jsonview/rel ... ter=v1.2.1

I've got 0.9 installed, and I don't think it was updated for WebExtensions until 2.0, so hopefully one of the XPIs from there should work.

therube

User avatar
 
Posts: 20888
Joined: March 10th, 2004, 9:59 pm
Location: Maryland USA

Post Posted July 15th, 2021, 10:28 am

v1.2.4 looks to work.
But - there is no .xpi, so you have to "make" one.

"All" that needs to be added is an install.rdf.

You can pull that from the v1.0.2 version (.xpi).
Also, its install.rdf needs a SeaMonkey section added to it.

Code: Select all
   <em:targetApplication>
      <Description>
        <em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
        <em:minVersion>2.42</em:minVersion>
        <em:maxVersion>*</em:maxVersion>
      </Description>
   </em:targetApplication>

(While in there, you might want to change em:version to <em:version>1.2.4</em:version>.)

After that, just ZIP it up correctly & change the extension from .zip to .xpi.
("Correctly". install.rdf & all else including subdirectories should be in the topmost directory, not in a subdirectory.)

Note that there will be extraneous stuff in there, but it shouldn't matter.

If you've done that correctly, it should install & work.
(Or, you could just use the v1.0.2 version without the extra work ;-).)


(Starting at 2.0.0, they went webextension.)
Fire 750, bring back 250.
Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14 Pinball CopyURL+ FetchTextURL FlashGot NoScript

Return to SeaMonkey General


Who is online

Users browsing this forum: No registered users and 1 guest