@advanced-rest-client/json-table

中文文档
3.3.1发布于 2022/01/05Apache-2.0ESM + CJS近 30 天下载 3242

A table view from a JSON structure

原始使用文档
文档目录9 节
  1. Content actions
  2. Usage
  3. Installation
  4. In an html file
  5. In a LitElement
  6. In a Polymer 3 element
  7. Development
  8. Running the demo locally
  9. Running the tests

json-table

Published on NPM

Tests and publishing

A table view from the JSON structure.

The element renders a table and / or list view from a JSON object. If JSON is an array it renders a table view. For objects it renders a list view.

Complex object are represented as an embedded view of a list or table inside the parent object representation. That may create very complex structure and lead to performance issues when computing data model and building the DOM. Therefore the element will only build the first level of the view. If the object / array contains other objects / arrays it will show only a button to display embedded objects. That should prohibit from freezing the UI while rendering the view.

Another optimization is pagination (disabled by default). After setting the paginate property array tables will contain a pagination with itemsPerPage items rendered at a time. The user can change number of items at any time.

<json-table json="[...]" paginate itemsPerPage="15"></json-table>

Content actions

The element can render an actions pane above the table / list view. Action pane is to display content actions that is relevant in context of the content displayed below the buttons. It should be icon buttons list or just buttons added to this view.

Buttons must have slot="content-action" attribute set to be included to this view.

<json-table json='{"json": "test"}'>
 <paper-icon-button slot="content-action" title="Copy content to clipboard" icon="arc:content-copy"></paper-icon-button>
</json-table>

Usage

Installation

npm install --save @advanced-rest-client/json-table

In an html file

<html>
  <head>
    <script type="module">
      import '@advanced-rest-client/json-table/json-table.js';
    </script>
  </head>
  <body>
    <json-table paginate json="..."></json-table>
  </body>
</html>

In a LitElement

import { LitElement, html } from 'lit-element';
import '@advanced-rest-client/json-table/json-table.js';

class SampleElement extends PolymerElement {
  render() {
    return html`
    <json-table .json="${this.json}" paginate></json-table>
    `;
  }
}
customElements.define('sample-element', SampleElement);

In a Polymer 3 element

import {PolymerElement, html} from '@polymer/polymer/polymer-element.js';
import '@advanced-rest-client/json-table/json-table.js';

class SampleElement extends PolymerElement {
  static get template() {
    return html`
    <json-table json="[[json]]"></json-table>
    `;
  }
}
customElements.define('sample-element', SampleElement);

Development

git clone https://github.com/advanced-rest-client/json-table
cd json-table
npm install

Running the demo locally

npm start

Running the tests

npm test

版本与发布记录

@advanced-rest-client/json-table 共发布 15 个版本,首次发布于 2018/05/19;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.3.1latest2022/01/054 年前
3.3.02021/03/195 年前
3.2.02020/07/076 年前
3.1.52019/12/046 年前
3.1.42019/11/216 年前
3.1.32019/09/277 年前

关于 @advanced-rest-client/json-table 的常见问题

@advanced-rest-client/json-table 是什么?

A table view from a JSON structure

如何安装 @advanced-rest-client/json-table?

在项目目录运行 npm install @advanced-rest-client/json-table,或使用 pnpm add / yarn add / bun add。

@advanced-rest-client/json-table 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/advanced-rest-client__json-table 是否存在。

@advanced-rest-client/json-table 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@advanced-rest-client/json-table 可以商用吗?

@advanced-rest-client/json-table 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@advanced-rest-client/json-table 的下载量有多少?

根据 npm 官方下载统计,@advanced-rest-client/json-table 在 2026/10/05 – 2026/11/03 这 30 天内被下载 3,242 次,日均约 108 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@advanced-rest-client/json-table 还在维护吗?

最新版本 3.3.1 发布于 2022/01/05(4 年前);至今共发布 15 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/05/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。