Socket
Book a DemoInstallSign in
Socket

json-ast-visitor

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-ast-visitor

JSON abstract syntax tree parser, visitor and serializer

latest
Source
npmnpm
Version
1.0.4
Version published
Weekly downloads
0
-100%
Maintainers
1
Weekly downloads
 
Created
Source

JSON AST Visitor

JSON abstract syntax tree parser, visitor and serializer.

import {parseJson, traverseJsonAst, generateJson, JsonVisitor, NumberNode} from 'json-ast-visitor';

const json = [{foo: 'bar'}];
const jsonAst = parseJson(json);

class FooVisitor extends JsonVisitor {

  visitString(node) {
    if (node.getKey() === 'foo') {
      node.replace(new NumberNode(123));
    }
  }
}

traverseJsonAst(jsonAst, new FooVisitor())
  .then(generateJson)
  .then(json => console.log(json)) // → [{foo: 123}]

Scripts

npm run flow Run Flow type checks.

npm test Run Jest test suite.

npm run build Build project into target/out directory.

FAQs

Package last updated on 19 Dec 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts