Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including json_ml with all npm packages installed. Try it out:

var jsonMl = require("json_ml")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

json_ml v0.0.2

JsonML parse/stringify function.

Json_ml NPM version Build Status Coverage Status

Sauce Test Status

JsonML parse/stringify function

Installation

Via npm

$ npm install json_ml --save
var JsonML= require('json_ml');
console.log(JsonML); //object

Via bower

$ bower install json_ml --save
<script src="bower_components/json_ml/json_ml.min.js"></script>
<script>
  console.log(JsonML); //object
</script>

API

See: http://www.jsonml.org/

JsonML.parse(html, trim=true) -> [Element,Element,...]

Convert HTML string to JsonML Elements.

JsonML.parse('<ul><li style="color:red">First Item</li><li title="Some hover text." style="color:green">Second Item</li><li><span class="code-example-third">Third</span>Item</li></ul>');
//[
//  [
//    "ul",
//    [
//      "li",
//      {
//        "style": "color:red"
//      }
//    ],
//    [
//      "li",
//      {
//        "title": "Some hover text.",
//        "style": "color:green"
//      }
//    ],
//    [
//      "li",
//      [
//        "span",
//        {
//          "class": "code-example-third"
//        }
//      ]
//    ]
//  ]
//]

JsonML.stringify(object, replacer, indent) -> HTML

Convert JsonML Elements to HTML string.

JsonML.stringify([['ul',['li',{style:"color:red"}],['li',{title:"Some hover text.",style:"color:green"}],['li',['span',{class:'code-example-third'}]]]],null,2);
//<ul>
//  <li style="color:red"></li>
//  <li title="Some hover text." style="color:green"></li>
//  <li><span class="code-example-third"></span></li>
//</ul>

License

MIT

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free