Simple tool to transform svg
files and Strings into Object
or JSON
.
Useful to manipulate SVG
with js
, to store in noSQL databses.
This is the new version of svgson
Install
yarn add svgson-next
Usage
const svgson = // ----------------------------// Convert SVG to JSON AST// ----------------------------svgson
Test in browser here
API
svgson.parse
svgson
Returns: Promise
-
input
Type:
String
-
options.transformNode
Function to apply on each node when parsing, useful when need to reshape nodes or set default attributes.
Type:
Function
that returns the nodeDefault:
{return node} -
options.compat
Use keys from previuos version of
svgson
Type:
Boolean
Default:
false
-
options.camelcase
Apply
camelCase
into attributesType:
Boolean
Default:
false
svgson.stringify
svg = svgson
-
Pretty Printing
In order to generate pretty formatted SVG output, use
pretty
npm module:pretty =formatted =
Related
svgson-cli Transform SVG into Object
from the Command Line
element-to-path Convert SVG element into path
path-that-svg Convert entire SVG with path
svg-path-tools Tools to manipulate SVG path
(d)
License
MIT © Lionel T