Befor generating

This commit is contained in:
marys
2026-06-01 13:17:37 +02:00
parent 3383f4bf4a
commit 1aa1b5f625
6756 changed files with 649946 additions and 1 deletions
+36
View File
@@ -0,0 +1,36 @@
## v2.1.0
- Added Emoji support
## v2.0.7
- Decreased minimal NodeJS version to 4 (minimal NodeJS version 6 will be in the next major version of "json-to-ast")
## v2.0.5
- Increased minimal NodeJS version to 6
## v2.0.0
- Over-escaped identifier's value fixing (https://github.com/vtrushin/json-to-ast/issues/17)
- Changed case for node type names
- Changed option "verbose" parameter to "loc"
- Changed "rawValue" to "raw"
- Added "raw" to "Identifier" node
- Added pretty message output
## v2.0.0-alpha1.4
- Changed error's view
## v2.0.0-alpha1.3
- Fixed issue [Infinite loop in parseObject for empty objects when !verbose](https://github.com/vtrushin/json-to-ast/issues/15)
## v2.0.0-alpha1.1
- Added tests from https://github.com/nst/JSONTestSuite
- Changed "value" node to "literal"
- Added "rawValue" for "literal". "value" is cast to type now
- Changed "key" node to "identifier"
- Renamed "position" to "loc"
- Renamed "char" in "loc" to "offset"
- Added "source" to "loc"
## v1.2.15
- Fixed unicode parser bug
+19
View File
@@ -0,0 +1,19 @@
Copyright (C) 2016 by Vlad Trushin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+139
View File
@@ -0,0 +1,139 @@
[npm-icon]: https://img.shields.io/npm/v/json-to-ast.svg
[npm-downloads-icon]: https://img.shields.io/npm/dm/json-to-ast.svg
[npm-url]: https://www.npmjs.com/package/json-to-ast
[node-versions-icon]: https://img.shields.io/node/v/json-to-ast.svg
[node-url]: https://nodejs.org
[test-icon]: https://travis-ci.org/vtrushin/json-to-ast.svg?branch=master
[test-url]: https://travis-ci.org/vtrushin/json-to-ast
[coverage-icon]: https://coveralls.io/repos/github/vtrushin/json-to-ast/badge.svg?branch=master
[coverage-url]: https://coveralls.io/github/vtrushin/json-to-ast?branch=master
[astexplorer-url]: https://astexplorer.net/#/gist/6e328cf76a27ca85e552c9cb583cdd74/1077c8842337972509a29bc9063d17bf90a1a492
# JSON AST parser
[![NPM][npm-icon]][npm-url]
[![NPM downloads][npm-downloads-icon]][npm-url]
[![Requirements][node-versions-icon]][node-url]
[![Travis-CI][test-icon]][test-url]
## Install
```
> npm install json-to-ast
```
## Usage
```js
const parse = require('json-to-ast');
const settings = {
// Appends location information. Default is <true>
loc: true,
// Appends source information to nodes location. Default is <null>
source: 'data.json'
};
parse('{"a": 1}', settings);
```
Output
```js
{
type: 'Object',
children: [
{
type: 'Property',
key: {
type: 'Identifier',
value: 'a',
raw: '"a"',
loc: {
start: { line: 1, column: 2, offset: 1 },
end: { line: 1, column: 5, offset: 4 },
source: 'data.json'
}
},
value: {
type: 'Literal',
value: 1,
raw: '1',
loc: {
start: { line: 1, column: 7, offset: 6 },
end: { line: 1, column: 8, offset: 7 },
source: 'data.json'
}
},
loc: {
start: { line: 1, column: 2, offset: 1 },
end: { line: 1, column: 8, offset: 7 },
source: 'data.json'
}
}
],
loc: {
start: { line: 1, column: 1, offset: 0 },
end: { line: 1, column: 9, offset: 8 },
source: 'data.json'
}
}
```
## Node types
Object:
```js
{
type: 'Object',
children: <Property>[],
loc?: Object
}
```
Property:
```js
{
type: 'Property',
key: <Identifier>,
value: Object | Array | <Literal>,
loc?: Object
}
```
Identifier:
```js
{
type: 'Identifier',
value: string,
raw: string,
loc?: Object
}
```
Array:
```js
{
type: 'Array',
children: (Object | Array | <Literal>)[],
loc?: Object
}
```
Literal:
```js
{
type: 'Literal',
value: string | number | boolean | null,
raw: string,
loc?: Object
}
```
## AST explorer
[Try it online][astexplorer-url] on [astexplorer.net](https://astexplorer.net/)
## License
MIT
File diff suppressed because it is too large Load Diff
+58
View File
@@ -0,0 +1,58 @@
{
"name": "json-to-ast",
"version": "2.1.0",
"author": "Vlad Trushin",
"description": "JSON AST parser",
"homepage": "https://github.com/vtrushin/json-to-ast",
"repository": "vtrushin/json-to-ast",
"maintainers": [
{
"name": "Vlad Trushin <monospectr@mail.ru> (https://github.com/vtrushin)",
"email": "monospectr@mail.ru",
"github-username": "vtrushin"
}
],
"keywords": [
"json-parser",
"parser",
"ast",
"json",
"tree"
],
"main": "build.js",
"files": [
"build.js",
"LICENSE",
"README.md",
"CHANGELOG.md"
],
"engines": {
"node": ">= 4"
},
"scripts": {
"build": "rollup -c",
"watch": "rollup -c -w",
"pretest": "npm run build",
"test": "mocha",
"prepublishOnly": "npm run build"
},
"devDependencies": {
"babel-core": "^6.26.0",
"babel-helpers": "^6.24.1",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-3": "^6.24.1",
"coveralls": "^3.0.2",
"mocha": "5.2.0",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-commonjs": "^8.2.4",
"rollup-plugin-node-resolve": "^3.0.0"
},
"dependencies": {
"code-error-fragment": "0.0.230",
"grapheme-splitter": "^1.0.4"
},
"license": "MIT"
}