npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

json-show-off

v1.2.0

Published

Generate self sufficient html table snippets from json objects

Downloads

14

Readme

json-show-off 🕺

gzipped size dependencies License: MIT

Generate self sufficient html table snippets from json objects

It turns out that not everybody enjoys trawling thorough json as a way of absorbing data.

json-show-off takes a json object and returns nested html tables with some sugar.

Installation

npm install json-show-off --save

or

yarn add json-show-off

Usage

import showOff from "json-show-off";

jsonObject = {key: value};

showOff(jsonObject);

Style Overrides

jsonObject = {key: value};

customStyles = {
  table: `
    border-collapse: collapse; 
    color:pink;
    text-align:centre; 
    padding:10px;`
}

showOff(jsonObject, customStyles);

Default Styles

Any off the keys below can be overridden with valid css

{
  details: "text-indent:6px; font-family: Arial;",
  table: "font-family: Arial; border-collapse: collapse; color:white; text-align:left; padding:6px;",
  column: "border:1px solid #555; padding:10px;",
  header: "border:1px solid #555; padding:10px; font-weight:bold;",
  caption: "font-size:smaller; text-align:centre; padding:4px 0; color:white",
  captionPrefix: "color:#5ECBEE; font-style:italic",
  captionSuffix: "color:#A9E023",
  key: "text-align:right; font-weight:bold; color:white;",
  object: "background-color:#222;",
  array: "background-color:#2F2F2F;",
  null: "color:#AD83FE;",
  string: "color:#FBF670;",
  number: "color:#AD83FE;",
  true: "color:#AD83FE;",
  false: "color:#AD83FE;",
  link: "color: #5ECBEE;",
  img: "max-height: 8em; max-width: 8em;"
}

Setting Overrides

jsonObject = {key: value};

customSettings = {
  expandOnLoad: false
}

showOff(jsonObject, null, customSettings);

Default Settings

{
  expandOnLoad: true,
  horizontalArrayView: true,
  displayLinks: false,
  displayImages: false,
  hideObjectDetails: false,
}

Example

import showOff from "json-show-off";

jsonObject =  {
  name: "Can",
  formed: 1968,
  active: false,
  albums: [
    {
      name: "Ege Bamyasi",
      year: 1972,
      personnel: {
        musicians: [
          { name: "Holger Czukay", role: "bass" },
          { name: "Michael Karoli", role: "guitar" },
          { name: "Jaki Liebezeit", role: "drums" },
          { name: "Irmin Schmidt", role: "keyboards" },
          { name: "Damo Suzuki", role: "vocals" }
        ],
        production: [
          { name: "Holger Czukay", role: "engineering / editing" },
          { name: "Ingo Trauer", role: "artwork" },
          { name: "Richard J. Rudow", role: "design" }
        ]
      },
      singles: [
        { name: "Spoon", year: 1971 },
        { name: "Vitamin C", year: 1972 }
      ]
    }
  ]
};

document.write(showOff(showOff));

Rendered Output

Example of Rendered Output

License

json-show-off is licensed as MIT.