# svg-json-parser

> converting SVG Elements to JSON Object

Latest version **0.7.3** (published 2017-04-14) · ISC license · 0 weekly downloads

## Install

```sh
npm install svg-json-parser
pnpm add svg-json-parser
yarn add svg-json-parser
bun add svg-json-parser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.7.3 |
| Published | 2017-04-14 |
| First published | 2016-07-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | David Nalchevnidze |
| Maintainers | nalchevanidze |
| Keywords | svg-json-parser |

## Links

- npm: https://www.npmjs.com/package/svg-json-parser
- npm.io page: https://npm.io/package/svg-json-parser

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.7.3 (latest) — 2017-04-14
- 0.7.1 — 2017-04-13
- 0.7.0 — 2017-04-12
- 0.6.8 — 2016-09-03
- 0.6.7 — 2016-09-03
- 0.6.5 — 2016-09-03
- 0.6.4 — 2016-09-01
- 0.6.3 — 2016-08-30
- 0.6.2 — 2016-07-31
- 0.6.1 — 2016-07-31
- 0.6.0 — 2016-07-31

## README

# svg-json-parser

this App Converts SVG Element to JSON.


```html

npm install svg-json-parser;

var svgParser = require("svg-json-parser");

app.json.lib('lib.svg','Output file path Without .json');
```

<h6>converted Object</h6>
```html

{
  node:"svg",
  id:"svglib",
  children:[
    {"node":"g",id:apple,children:[{node:"path",attr:{d:"M10..",fill="red"}},.....]},
    {"node":"path",id:orange,attr:{fill="#FF3456"}},
    .....
  ]
}
```
<h6>lib method </h6>

returns SVG elements as the properties of the object, will be included only elements with ID attribute; only direct children need id Attributes. and can be passed only: SVG or SVG "defs" element.

```html
<svg>
  // it not, no id  <path  d="M0..." />
    <g id="work">
        <path d="M0..." />
        <path d="M0..." />
    </g>
    <path id="gmail" d="M0..." />
    .......
</svg>

var  svglib = svgParser.json.lib();
{
  work:{
    node:"g",
    id:"work",
    children:[
      {"node":"path",attr{"d":"M0..."}},
      {"node":"path",attr{"d":"M0..."}}
    ]
  },
  gmail:{
    node:"path",
    id:"gmail",
    attr{"d":"M0..."}}
  },.....
}
```
<h6>you can use lib object in react:</h6>

```html

class Icon extends React.Component {
  render(){
    var s = svglib[this.props.id];
    if(s.node=="g"){return (<g >{sv.children.map((e,i)=><path  d={e.d} fill={e.fill} key={i} ></path>)}</g>);}
    else if(s.node=="path"){return (<path  d={s.d} fill={s.fill} ></path>);}
  }
}

<Icon id='work' />

```

---
_Source: https://npm.io/package/svg-json-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
