{"name":"mojangson","version":"1.1.0","description":"A mojangson parser written in node.js","main":"index.js","repository":{"type":"git","url":"git://github.com/rom1504/node-mojangson.git"},"keywords":["mojangson"],"author":{"name":"Romain Beaumont","email":"romain.rom1@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/rom1504/node-mojangson/issues"},"devDependencies":{"mocha":"^7.1.2","standard":"^14.3.4"},"scripts":{"prepublish":"nearleyc grammar.ne -o grammar.js","test":"mocha --reporter spec","pretest":"npm run lint","lint":"standard","fix":"standard --fix"},"dependencies":{"nearley":"^2.19.5"},"gitHead":"e2c800c1f78d79a49cf42c392e7a1ded8bbf62b7","homepage":"https://github.com/rom1504/node-mojangson#readme","_id":"mojangson@1.1.0","_nodeVersion":"12.18.3","_npmVersion":"6.14.7","dist":{"integrity":"sha512-6+ZyQF1RSGtzTJWGzqw3qw9PuP7/KeN0JDauwXtWWN1BYSm18IiNcimXepltevXZRHhpLQpWyLpWf1uV7PYyhw==","shasum":"63a0cb80074f8fcb5d896b54b3711fb8d1d24a2c","tarball":"http://registry-npm.ywwl.com/mojangson/download/mojangson-1.1.0.tgz","fileCount":11,"unpackedSize":16669,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfNHt/CRA9TVsSAnZWagAAjuIP/2S+q5+xKc9lEPw/OydS\nsM+YlWqStiz88GIXqRry6INiYOBeJms/VitsqXZhAxPv+vu3P3mdTB2yTwQm\n5M1dzZ1Kd+2fKnnV0gxas1xC+BWE9mgf8QM29fQRYkNZ/77u/4GGA4UveKQu\nRtA7MTQAjDg7qE3opcU4u2jponnFHoW2cjgYuOb5J+UCkSuZMeuSTM8rMc6W\nIzr69TOUPmrIQ2A83KQySXpsShEe8hPxIMJWlYJrRKnCRWyUSfau88Pra2UH\n7eJJw7+CfRh5bXxnt7ZFeZ9dh1GQt/JncELKqv9LYqg6NYVS9N8k+ISoUpnI\nECghnXx84ZIk1YdTZ2FexvZApYS07HPceju+Y8OpuGroL4m1TBj/XB5tQFmv\nN0acho1haiGbrghjdU0AvOtm/llO57rPW+fTWJPN6s2KJsOp842xIcloJ7Wx\nMCF5zqK/PvDDlRFlLACVRSiNVVfRWldIp1MC2CanOPo/z+CRv37Fb5Wm3HCt\nRznAqdolWOOfz0hoX/kMAxxVugHgHsn94jA5nBr3hITyVmhzKVlTvSEJ+NQO\nCkPW3wPZYkbZN5V4EGlWqx/IFhidUj2RcmClt9Sl3I+6WVkeJFxvtzALGA9j\nNXPhm0K3gP1NwZLSBG4oVTGYYsPhOlSHW97pHunQcXlVMhm3izOt+Djhuisc\n7jIi\r\n=druj\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIChhw/A7GfGwqJebNnpnw6THGW3VMCxHnnWXecVR8snQAiAXPkff9865NkIIJzpvBWTZkb3UImSQ8c6xdYASB6+pNw=="}],"size":4705,"noattachment":false,"key":"/mojangson/-/mojangson-1.1.0.tgz"},"maintainers":[{"name":"rom1504","email":"romain.rom1@gmail.com"}],"_npmUser":{"name":"rom1504","email":"romain.rom1@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mojangson_1.1.0_1597275007275_0.9898603309807292"},"_hasShrinkwrap":false,"readme":"# node-mojangson\n[![NPM version](https://badge.fury.io/js/mojangson.svg)](http://badge.fury.io/js/mojangson) ![CI](https://github.com/PrismarineJS/node-mojangson/workflows/CI/badge.svg)\n\nnode-mojangson is a mojangson parser.\n\n## Mojangson specification\nMojangson is mojang's variant of json. It is basically json with the following changes :\n\n * array can be indexed (example : `[0:\"v1\",1:\"v2\",2:\"v3\"]`)\n * array and object can have trailing comma (example : `[5,4,3,]` and `{\"a\":5,\"b\":6,}`)\n * there can be string without quote (example : `{mykey:myvalue}`)\n * numbers can be suffixed by b, s, l, f, d, i or the same in upper case (example : `{number:5b}`)\n * mojangson stays a superset of json : every json is a mojangson\n\n Reference https://minecraft.gamepedia.com/Commands#Data_tags\n\n## Parser\nThis parser is build using nearley.\n\nSee the [grammar](grammar.ne) and the examples in the [test](test/test.js) for more information.\n\n## Usage\nUsage example :\n\n```js\nconst mojangson = require('mojangson')\n\nconst data = mojangson.parse('{mykey:myvalue}')\n\n// print the parsed data\nconsole.log(data)\n\n// print the simplified data\ncondole.log(mojangson.simplify(data))\n```\n\nThe provided method `mojangson.parse` return a javascript object corresponding to the mojangson passed in input.\n\n`mojangson.simplify` returns a simplified representation : keep only the value to remove one level. This loses the types so you cannot use the resulting representation to write it back.\n\n`mojangson.stringify` will take a js object with types and values for mojangson and make it into a normalized mojangson string\n\n```js\nconst mojangson = require('mojangson')\nconst data = mojangson.stringify({ type: 'list', value: { type: 'string', value: [ 'z1', 'z2' ] } })\nconsole.log(data) // => [z1,z2]\n```\n\nAnother example, the provided method `mojangson.normalize` takes a string of mojangson and normalizes it in the shortest way to retain all data. Comparing it to the original will tell you if you have the shortest equivalent to a string of mojangson.\n\n```js\nconst mojangson = require('mojangson')\nconst original = '[0:\"z1\",1:\"z2\"]'\nconst data = mojangson.normalize(original)\nconsole.log(data) // => [z1,z2]\nconst optimized = original === data\nconsole.log(optimized) // => false\n```\n\n\n## History\n\n### 2.0.4\n\n* fix publish\n\n### 2.0.3\n\n* Fix simplifying of arrays throwing error (@Lianecx)\n* Escape new lines in text (@U9G)\n\n### 2.0.2\n\n* fixes issue where strings starting with a number would be parsed as a number (@U9G)\n\n### 2.0.1\n\n* fix escaping some chars in mojangson.stringify (@U9G)\n* update grammar for unicode escaped strings (@U9G)\n* fix parsing of escaped characters (@Majorblake)\n\n### 2.0.0\n\n* Changes output format to include types (@Karang)\n* add simplify function\n* Add stringify function to go back to mojangson (@U9G)\n\n### 1.1.1\n\n* Fix empty string parsing (thanks @IdanHo)\n\n### 1.1.0\n\n* switch to nearley parser for a better handling for mojangson (thanks @Karang)\n\n### 1.0.0\n\n* stop printing error\n\n### 0.2.4\n\n* add support for double and int\n\n### 0.2.3\n\n* fix release about grammar.js still containing the cli\n\n### 0.2.2\n\n* disable jison cli to make mojangson compatible with browserify\n\n### 0.2.1\n\n* fix state conflict due to recent trailing comma fix\n\n### 0.2.0\n\n* Rename npm package to mojangson\n* fix trailing comma in arrays\n\n### 0.1.1\n\n* better error displaying\n\n### 0.1\n\n* First release, basic functionality\n","publish_time":1597275007397,"_cnpm_publish_time":1597275007397,"dist-tags":{"latest":"2.1.0"}}