Emuto is a small language for manipulating and restructuring JSON
source link: https://www.tuicool.com/articles/hit/mUvyAzm
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Website • Tutorial • Live demo ••Compile-to-JS version
Emuto is a small language for manipulating and restructuring JSON and other data files. Emuto is inspired by jq and GraphQL
Getting started
Emuto as a CLI tool
npm install -g emuto emuto-cli
Webpack loader for emuto
yarn add --dev emuto emuto-loader
Read more in the Webpack guide
What is emuto good for? Examples
Number of items in JSON file
curl my_file.json | emuto 'length'
Your karma on HackerNews
curl https://hacker-news.firebaseio.com/v0/user/kantord.json -s | emuto '$.karma'
See number of NPM dependencies
cat package.json | emuto -c '$.dependencies | keys | length'
List available scripts in package.json
cat package.json | emuto -c '$.scripts | keys | join " · "'
Get only the relevant data from a huge JSON file
curl https://api.github.com/repos/stedolan/jq/commits |\ emuto -c 'map ($ => $ { commit { message } committer { login } } )'
Automate the restructuring of data by creating scripts with emuto
restructure.emu
#! emuto -s $ | map ($ => $ { commit { message } committer { login } } ) | map ($ => { "committer": $.committer.login, "message": $.commit.message, })
Calling your script
curl https://api.github.com/repos/stedolan/jq/commits | ./restructure.emu
Contributing Guide
Read our contributing guide to learn about our development process, how to create bugfixes and improvements, and how to build and test your changes to emuto.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK