Detalhes do pacote

remixml-jsobj

BuGlessRB3(ISC OR GPL-3.0)6.1.0

Remixml component that allows converting between HTML and JSON

remixml, browser, render, DOM

readme (leia-me)

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.