Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/afeiship/next-dom2json
Dom to json for next.
https://github.com/afeiship/next-dom2json
dom json next walk
Last synced: 8 days ago
JSON representation
Dom to json for next.
- Host: GitHub
- URL: https://github.com/afeiship/next-dom2json
- Owner: afeiship
- License: mit
- Created: 2020-09-06T01:46:59.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-20T03:24:57.000Z (about 4 years ago)
- Last Synced: 2024-12-10T10:24:55.958Z (12 days ago)
- Topics: dom, json, next, walk
- Language: JavaScript
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# next-dom2json
> Dom to json for next.[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]## installation
```bash
npm install -S @jswork/next-dom2json
```## usage
```js
import '@jswork/next-dom2json';const domElement = `
123
abc
def
`;
const dom = new JSDOM(domElement);
const el = dom.window.document.querySelector('.list_item');
const json = nx.dom2json(el);// results:
/*
{
nodeName: 'div',
nodeType: 1,
attributes: {
class: 'list_item odd',
'data-value': 'v1',
itemscope: '',
itemtype: 'http://schema.org/Movie'
},
childNodes: [
{
nodeName: '#text',
nodeType: 3,
nodeValue: '\n 123\n ',
childNodes: []
},
{
nodeName: 'span',
nodeType: 1,
attributes: {},
childNodes: [
{
nodeName: '#text',
nodeType: 3,
nodeValue: 'abc',
childNodes: []
}
]
},
{
nodeName: '#text',
nodeType: 3,
nodeValue: '\n ',
childNodes: []
},
{
nodeName: 'strong',
nodeType: 1,
attributes: {},
childNodes: [
{
nodeName: '#text',
nodeType: 3,
nodeValue: 'def',
childNodes: []
}
]
},
{
nodeName: '#text',
nodeType: 3,
nodeValue: '\n ',
childNodes: []
}
]
}
*/
```## license
Code released under [the MIT license](https://github.com/afeiship/next-dom2json/blob/master/LICENSE.txt).[version-image]: https://img.shields.io/npm/v/@jswork/next-dom2json
[version-url]: https://npmjs.org/package/@jswork/next-dom2json[license-image]: https://img.shields.io/npm/l/@jswork/next-dom2json
[license-url]: https://github.com/afeiship/next-dom2json/blob/master/LICENSE.txt[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/next-dom2json
[size-url]: https://github.com/afeiship/next-dom2json/blob/master/dist/next-dom2json.min.js[download-image]: https://img.shields.io/npm/dm/@jswork/next-dom2json
[download-url]: https://www.npmjs.com/package/@jswork/next-dom2json