Skip to content

Installation

Xavier Badosa edited this page Nov 24, 2019 · 16 revisions

WikiInstallation

This is the documentation of JSON-stat Javascript Toolkit version 0. Version 1 has slightly different features and installation procedures that are documented elsewhere.

JJT can be run on a server as a Node.js module. Type the following command to install:

npm install jsonstat

JJT can also be run on a browser as a library and as an ECMAScript module.

To include the JJT library in your webpage, download the latest version of json-stat.js and link to your own copy of the file:

<script src="/your-js-dir/json-stat.js"></script>

json-stat.js is also available from several CDNs (jsDelivr, unpkg):

<script src="https://cdn.jsdelivr.net/npm/jsonstat"></script>
<script src="https://unpkg.com/jsonstat"></script>

Or using a particular version in production:

<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://unpkg.com/[email protected]"></script>

The JJT library works on any browser.

To import the JJT ECMAScript module in your webpage, download the latest version of export.mjs and link to your own copy of the file:

<script type="module">
  import { JSONstat } from "/your-js-dir/export.mjs";
  //Or if for some reason you need to check the JJT version:
  //import { JSONstat, version as JSONstatVersion} from "/your-js-dir/export.mjs";
</script>

export.mjs is also available from several CDNs (jsDelivr, unpkg):

<script type="module">
  import { JSONstat } from "https://cdn.jsdelivr.net/npm/jsonstat/export.mjs";
</script>
<script type="module">
  import { JSONstat } from "https://unpkg.com/jsonstat/export.mjs";
</script>

Or using a particular version in production:

<script type="module">
  import { JSONstat } from "https://cdn.jsdelivr.net/npm/[email protected]/export.mjs";
</script>
<script type="module">
  import { JSONstat } from "https://unpkg.com/[email protected]/export.mjs";
</script>

The JJT ECMAScript module works on any browser that support ECMAScript modules.

The JSON-stat Javascript Toolkit (JJT) can be complemented with the JSON-stat Javascript Utilities Suite (JJUS), a high level library built on top of it.

Notes

Module versions

The module versions (CommonJS and ECMAScript) have all the functionality of the library version except the connection capabilities (JSONstat() accepts only a JSON-stat response object, not a URI string). Use Node.js’s built-in http module, or a module with a similar functionality (like request or got) to retrieve a remote JSON-stat response. See nodejs.js or our Tonic + npm code as an example.

Library version

When developing locally, your browser may enforce strict permissions for reading files out of the local file system. If you use JSONstat() with a URI string that points to a local file, you will need to set up a local web server first. When passing a URI string, take also into account that JSONstat() has limited old browsers support. Whenever you can, use an object instead.

Clone this wiki locally