remixml-jsobj

Remixml component that allows converting between HTML and JSON

Usage no npm install needed!

<script type="module">
  import remixmlJsobj from 'https://cdn.skypack.dev/remixml-jsobj';
</script>

README

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.