Extract JSON From HTML Using JavaScript – Temme

Category: Javascript , Recommended | October 29, 2018
Author:shinima
Views Total:93 views
Official Page:Go to website
Last Update:October 29, 2018
License:MIT

Preview:

Extract JSON From HTML Using JavaScript  – Temme

Description:

The Temme JavaScript library uses custom selectors to extract JSON from HTML using pure JavaScript.

How to use it:

Install the Temme library:

# Yarn
$ yarn add temme
# NPM
$ npm install temme --save

Import the Temme library.

// ES 6
import temme from 'temme';
// CommonJS:
const temme = require('temme');

Specify the selector.

const selector = 'div[color=$c]{$t};'

Define the HTML.

const html = '<div color="red">hello world</div>'

Extract JSON from HTML:

temme(html, selector)

This will output a JSON array:

{ c: 'red', t: 'hello world' }

Changelog:

v0.8.0 (10/29/2018)

  • Update

You Might Be Interested In:


Leave a Reply