Pipe JSON Data into Node.js via Command Line

I was trying to pipe JSON data into node.js as an object. I came across an answer on StackOverflow, which was about something else, but led me in the right direction.

I was able to do it via cat and node using the following command:

cat ./example.json | node <<< "var o = $(cat); console.log(o);"

Worked like a charm.

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by WordPress