Skip to content

snikch/pretty-json

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PRETTY JSON

Simple library to render/format a JS obj to an HTML view.

Live Demo

This is an live demo

Dependecies

  • Backbone (just code structure) / Underscore
  • JQuery (DOM manipulation)

Usage

//obj to render.
var obj = {
  name:'John Doe',
  age: 20,
  children:[{name:'Jack', age:5}, {name:'Ann', age:8}],
  wife:{name:'Jane Doe', age:28 }
}

var node = new PrettyJSON.view.Node({
  el:$('#elem'),
  data:obj
});

Properties.

el: DOM elem to append the JSON-HTML view.
data: the JSON data.
dateFormat: (optional) format date, ex: "DD/MM/YYYY HH24:MI:SS".

  • YYYY : year
  • YY : year
  • MM : month
  • DD : day
  • HH24 : hour 24-format
  • HH : hours
  • MI : minutes
  • SS : seconds

Methods

Node
expandAll: recursive open & render all nodes. (lazy render: the node will render only if it's expanded)
collapseAll: close (Hide) all nodes.

Events

Node
collapse: trigger when a node is show or hide. (event)
mouseover: trigger when mouse over a node. (path)
mouseout: trigger when mouse out the node (event)

  • Note: "node" is an Obj or an Array.
  • Note : only tested in Chrome & FireFox.

About

Simple library to render/format a JS obj to an HTML view. (De[back]boned)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 84.5%
  • JavaScript 7.5%
  • C 5.5%
  • Shell 1.8%
  • CSS 0.7%