remixml-jsobj

6.1.0 • Public • Published

Remixml converter between HTML and JSON

NPM version Downloads Rate on Openbase

Remixml component that renders directly to and from the javascript objects that can be converted to JSON and back.

Basic usage

From HTML to JSON and back:

var htmlstring = "<h1>This is a test</h1><p class='main'>Foo Bar</p>";
var abstract = Remixml.compile(htmlstring)({});
Remixmljsobj.abstract2jsobj(abstract);
console.log(JSON.stringify(abstract));
Remixmljsobj.jsobj2abstract(abstract);
var newstring = Remixml.abstract2txt(abstract, 1);
console.log(newstring);

Requirements

It runs inside any webbrowser or NodeJS environment.

Reference documentation

  • Remixmljsobj.abstract2jsobj(abstract)
    Converts a DOM abstract into a Javascript object, the function is destructive to the abstract argument and performs an in-situ transformation. Use JSON.stringify() to turn it into JSON.
  • Remixmljsobj.jsobj2abstract(jsobj)
    Converts a Javascript object to a DOM abstract, the function is destructive to the abstract argument and performs an in-situ transformation. Use JSON.parse() to convert from JSON to the Javascript object.

References

Card-carrying member of the zerodeps movement.

Package Sidebar

Install

npm i remixml-jsobj

Weekly Downloads

5

Version

6.1.0

License

(ISC OR GPL-3.0)

Unpacked Size

14.4 kB

Total Files

13

Last publish

Collaborators

  • buglessrb