Module: microdata-to-json

This module provides the same functionality as module microdata-to-object, but the result is not a Javascript object but a JSON encoded string representation. The purpose of this module is to serve as a shortcut, instead of converting a ONE object in microdata form to a Javascript object and then JSON-stringify it this provides a more efficient path. Since no objects have to be created, both input and output are strings, this probably also conserves memory.

Source:

Methods

(static) convertMicrodataToJSON(html) → {string}

Parameters:
Name Type Description
html string

One object in HTML (MicroData) representation

Convert the microdata representation of a ONE object directly to a JSON string. This is the same parser as in microdata-to-object.js,

Source:
See:
Throws:
Error | Error
Returns:

Returns the JSON string version of the parsed microdata

Type: string

Example
const json = convertMicrodataToJSON(
  '<div itemscope itemtype="//refin.io/Person">' +
    '<span itemprop="email">winfried@mail.com</span>' +
  '</span>'
);
console.log(json);
// {"type":"Person","data":{"email":"winfried@mail.com"}}