Skip to content

naivefun/jquery-jsonview

This branch is 4 commits behind yesmeck/jquery-jsonview:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Apr 18, 2016
5487756 · Apr 18, 2016

History

77 Commits
Apr 18, 2016
Apr 18, 2016
Apr 13, 2016
May 17, 2014
Apr 17, 2016
Nov 9, 2015
Feb 11, 2016
Nov 9, 2015
Feb 11, 2016

Repository files navigation

jQuery JSONView

Formats & syntax highlights JSON.

Port of Ben Hollis's JSONView extension for Firefox: http://jsonview.com

Live demo

Usage

Example

var json = {"hey": "guy","anumber": 243,"anobject": {"whoa": "nuts","anarray": [1,2,"thr<h1>ee"], "more":"stuff"},"awesome": true,"bogus": false,"meaning": null, "japanese":"明日がある。", "link": "http://jsonview.com", "notLink": "http://jsonview.com is great"};

$(function() {
  $("#json").JSONView(json);
  // with options
  $("#json-collasped").JSONView(json, { collapsed: true });
});

Options

jQuery JSONView can be configured using the following options.

  • collapsed - Collapse all nodes when rendering first time, default is false.
  • nl2br - Convert new line to <br> in String, default is false.
  • recursive_collapser - Collapse nodes recursively, default is false.
  • escape - Escape HTML in key, default is true.
  • strict - In strict mode, invalid JSON value type will throw a error, default is false.

API

jQuery JSONView provide following methods to allow you control JSON nodes, all methods below accept a level argument to perform action on the specify node.

  • jQuery#JSONView('collapse', [level]) - Collapse nodes.
  • jQuery#JSONView('expand', [level]) - Expand nodes.
  • jQuery#JSONView('toggle', [level]) - Toggle nodes.

Licence

MIT

About

View JSON in a more readable format

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • CoffeeScript 79.2%
  • HTML 13.3%
  • CSS 7.5%