async-json-parser
Advanced tools
Comparing version 0.0.2 to 0.0.3
{ | ||
"name": "async-json-parser", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.mjs", |
# Async JSON parser | ||
## parse | ||
## parse, stringify | ||
```js | ||
import fs from 'fs'; | ||
import {parse} from 'async-json-parser'; | ||
import { parse, stringify } from 'async-json-parser'; | ||
import request from 'request'; | ||
const URL = 'http://auction-api-eu.worldofwarcraft.com/auction-data/258993a3c6b974ef3e6f22ea6f822720/auctions.json'; | ||
const get = (url) => { | ||
return new Promise(resolve => { | ||
request(url, (res, err, body) => { | ||
resolve(body) | ||
}) | ||
}) | ||
}; | ||
(async () => { | ||
const stream = fs.createReadStream('test.json'); | ||
const res = await parse(stream); | ||
console.log(+res['a1'][0].address.geo.lat === -37.3159); | ||
console.log(res['a457'][2].address.suite === 'Suite 847'); | ||
const data = await get(URL); | ||
const res = await parse(data); | ||
const str = await stringify(json); | ||
fs.writeFileSync('data.json', str); | ||
})(); | ||
``` | ||
## Parser | ||
```js | ||
@@ -28,14 +41,1 @@ import Parser from 'async-json-parser/parser' | ||
## stringify | ||
```js | ||
import fs from 'fs'; | ||
import {stringify} from 'async-json-parser'; | ||
import json from './test.json'; | ||
(async () => { | ||
const data = await stringify(json); | ||
fs.writeFileSync('data.json', data); | ||
})(); | ||
``` | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
4468
6
118
1