Installations
npm install json-parse-ast
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
14.15.4
NPM Version
7.5.4
Score
73.3
Supply Chain
84.7
Quality
75.6
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
JohannesOehm
Download Statistics
Total Downloads
16,533
Last Day
13
Last Week
51
Last Month
278
Last Year
4,090
GitHub Statistics
4 Stars
13 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Jun 04, 2024
Bundle Size
5.56 kB
Minified
1.58 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.8
Package Id
json-parse-ast@1.0.8
Unpacked Size
30.35 kB
Size
6.32 kB
File Count
10
NPM Version
7.5.4
Node Version
14.15.4
Total Downloads
Cumulative downloads
Total Downloads
16,533
Last Day
-31.6%
13
Compared to previous day
Last Week
-28.2%
51
Compared to previous week
Last Month
-8.3%
278
Compared to previous month
Last Year
-22.9%
4,090
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
1
json-parse-ast
JSON Tokenizer & AST (Abstract Syntax Tree) parser
Background
I wrote my custom parser since monaco's built-in JSON library does not expose any syntax tree which can be used to check position in file and enhance autocomplete experience.
Usage
Currently, only tokenizer is stable:
1var tokens = tokenize('{"json": "string"}'); //returns list of tokens 2//tokens have the following attributes 3// type: "inlinecomment"|"multilinecomment"|"whitespace"|"string"|"literal"|"number"|"punctuaction" 4// position: IRange compatible with monaco's IRange-interface 5// raw: string 6// value: string Unescaped JSON string, parsed number, parsed literal (null, true, false)
Tokenizer additional features
1var [path, willBeValue] = getPathInObject(tokenize('{"foo": {"bar": "')); 2//returns path == ["foo", "bar"] and willBeValue == true
Parser
1var ast = parseTokens(tokenize(testString)); 2//AST elements have 3// type 4// position: IRange 5// raw: string 6// value?: string 7// parent?: AST 8// children?: AST[] 9 10//Find node at specified position 11var node = findAtPosition(ast, {lineNumber: 4, column: 16})
Usage with monaco
This libraries intended use is for enhancing experience with custom JSON formats. See example use-cases below:
Enhancing autocomplete/IntelliSense
1monaco.languages.registerCompletionItemProvider('json', { 2 provideCompletionItems: function(model, position) { 3 let textUntilPosition = model.getValueInRange({startLineNumber: 1, startColumn: 1, endLineNumber: position.lineNumber, endColumn: position.column}); 4 let [jsonPath, willBeValue] = getPathInObject(tokenize(textUntilPosition)); 5 if (willBeValue && jsonPath[jsonPath.length-1] === "dependencies") { 6 return { suggestions: listDependencies() }; 7 } else { 8 return { suggestions: [] }; 9 } 10 } 11});

No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 0/13 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
20 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
1.3
/10
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More