Skip to content

Commit

Permalink
add command-line flag to support very big json objs. (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbc authored and mholt committed Aug 14, 2019
1 parent f223e87 commit 5036fd4
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions json-to-go.js
Expand Up @@ -398,10 +398,21 @@ function jsonToGo(json, typename, flatten = true)

if (typeof module != 'undefined') {
if (!module.parent) {
process.stdin.on('data', function(buf) {
const json = buf.toString('utf8')
console.log(jsonToGo(json).go)
})
if (process.argv.length > 2 && process.argv[2] === '-big') {
bufs = []
process.stdin.on('data', function(buf) {
bufs.push(buf)
})
process.stdin.on('end', function() {
const json = Buffer.concat(bufs).toString('utf8')
console.log(jsonToGo(json).go)
})
} else {
process.stdin.on('data', function(buf) {
const json = buf.toString('utf8')
console.log(jsonToGo(json).go)
})
}
} else {
module.exports = jsonToGo
}
Expand Down

0 comments on commit 5036fd4

Please sign in to comment.