Comments (2)
@agarrharr Well, there's a few things about your snippet.
The 'white' value was categorized as value, and not hue, and the trailing comma broke json.. I posted an updated version of your json here. https://jqplay.org/s/UDfm0I60UA
The corrected json snippet wouldn't have worked in vj, because the values were all inside the colors array. vj doesn't dig for values, it treats the outermost value as the core. So you would need to pre-process the json array with something like 'jq' to do a expose the [colors] array to the namespace. Then VJ can take it from there.
black category hue code {"rgba"=>[255, 255, 255, 1], "hex"=>"#000"} type primary
white category hue code {"rgba"=>[0, 0, 0, 1], "hex"=>"#FFF"}
red category hue code {"rgba"=>[255, 0, 0, 1], "hex"=>"#FF0"} type primary
blue category hue code {"rgba"=>[0, 0, 255, 1], "hex"=>"#00F"} type primary
yellow category hue code {"rgba"=>[255, 255, 0, 1], "hex"=>"#FF0"} type primary
green category hue code {"rgba"=>[0, 255, 0, 1], "hex"=>"#0F0"} type secondary
So the code array is still in an array, if you wanted to exclude that.
black category hue type primary
white category hue
red category hue type primary
blue category hue type primary
yellow category hue type primary
green category hue type secondary
That would wrap up the whole thing. If you wanted to include everything in code, you'd need to use jq
filter to add the flattened array to the containing array. Here's an example of hex value being taken out of the code array.
black type primary category hue hex #000 rgba [255, 255, 255, 1]
white type primary category hue hex #FFF rgba [0, 0, 0, 1]
red type primary category hue hex #FF0 rgba [255, 0, 0, 1]
blue type primary category hue hex #00F rgba [0, 0, 255, 1]
yellow type primary category hue hex #FF0 rgba [255, 255, 0, 1]
green type secondary category hue hex #0F0 rgba [0, 255, 0, 1]
Here's another example using OMDB
curl -s 'https://www.omdbapi.com/?s=ready&apikey=REDACTED' | jq '.Search[]' -rc | vj -c Year -p title -s Poster | sort -n
2000 Title Get Ready to Be Boyzvoiced Type movie imdbID tt0248036
2000 Title Ready to Rumble Type movie imdbID tt0217756
2008 Title Ready Type movie imdbID tt1156516
2011 Title Ready Type movie imdbID tt1708532
2018 Title Ready Player One Type movie imdbID tt1677720
1993–1997 Title Ready or Not Type series imdbID tt0106110
1994 Title Ready to Wear Type movie imdbID tt0110907
2009 Title Ready or Not Type movie imdbID tt0892094
2003 Title Ready, Steady, Charlie! Type movie imdbID tt0353161
2015 Title I'm Not Ready for Christmas Type movie imdbID tt5182120
The original json looked like this:
{
"Search": [
{
"Title": "Ready Player One",
"Year": "2018",
"imdbID": "tt1677720",
"Type": "movie",
"Poster": "https://m.media-amazon.com/images/M/MV5BY2JiYTNmZTctYTQ1OC00YjU4LWEwMjYtZjkwY2Y5MDI0OTU3XkEyXkFqcGdeQXVyNTI4MzE4MDU@._V1_SX300.jpg"
},
{
"Title": "Ready to Wear",
"Year": "1994",
"imdbID": "tt0110907",
"Type": "movie",
"Poster": "https://images-na.ssl-images-amazon.com/images/M/MV5BZWMwN2RiZDQtN2RkNS00YzJkLWI2ODMtODk1MzQxODE4NzU0XkEyXkFqcGdeQXVyMTQxNzMzNDI@._V1_SX300.jpg"
},
{
"Title": "Ready to Rumble",
"Year": "2000",
"imdbID": "tt0217756",
"Type": "movie",
"Poster": "https://m.media-amazon.com/images/M/MV5BMTYwMjYyOTA4OV5BMl5BanBnXkFtZTYwMDAyNjE3._V1_SX300.jpg"
},
{
"Title": "Ready",
"Year": "2011",
"imdbID": "tt1708532",
"Type": "movie",
"Poster": "https://ia.media-imdb.com/images/M/MV5BNzMzNzUxNzQxOF5BMl5BanBnXkFtZTgwMzYxODcwMzE@._V1_SX300.jpg"
},
{
"Title": "Ready or Not",
"Year": "1993–1997",
"imdbID": "tt0106110",
"Type": "series",
"Poster": "https://ia.media-imdb.com/images/M/MV5BMDE4ZWNjNjQtZThkMC00M2FhLWExYmMtZjI0YTMyOWQxYTI0XkEyXkFqcGdeQXVyNjExODE1MDc@._V1_SX300.jpg"
},
{
"Title": "Get Ready to Be Boyzvoiced",
"Year": "2000",
"imdbID": "tt0248036",
"Type": "movie",
"Poster": "https://images-na.ssl-images-amazon.com/images/M/MV5BYjc0ZjI5ODAtY2Y3Ni00NGM2LTg1ZmQtNDZkOWVhNGNmN2M3XkEyXkFqcGdeQXVyNDg1NjA2OA@@._V1_SX300.jpg"
},
{
"Title": "I'm Not Ready for Christmas",
"Year": "2015",
"imdbID": "tt5182120",
"Type": "movie",
"Poster": "https://images-na.ssl-images-amazon.com/images/M/MV5BMjI3NzUwMzI4OV5BMl5BanBnXkFtZTgwNjIwMTQ2ODE@._V1_SX300.jpg"
},
{
"Title": "Ready, Steady, Charlie!",
"Year": "2003",
"imdbID": "tt0353161",
"Type": "movie",
"Poster": "https://m.media-amazon.com/images/M/MV5BMTU1OTg2Mjk4NV5BMl5BanBnXkFtZTcwMDMxNzY5MQ@@._V1_SX300.jpg"
},
{
"Title": "Ready",
"Year": "2008",
"imdbID": "tt1156516",
"Type": "movie",
"Poster": "https://images-na.ssl-images-amazon.com/images/M/MV5BNDYzMWI2MDctMzEwOC00NWI5LTlmYmMtNDVmODlmMTM0ZjY0XkEyXkFqcGdeQXVyMzA0NTI2OTM@._V1_SX300.jpg"
},
{
"Title": "Ready or Not",
"Year": "2009",
"imdbID": "tt0892094",
"Type": "movie",
"Poster": "https://images-na.ssl-images-amazon.com/images/M/MV5BMTMyODg1NDY4N15BMl5BanBnXkFtZTcwMjk4NzI0MQ@@._V1_SX300.jpg"
}
],
"totalResults": "361",
"Response": "True"
}
The data I wanted VJ to work on was in the Search
var, so I used jq to output only that. VJ has a -d to set the default container, but I couldn't get it to work. I would love to get spaced/padding/justification on the output, but for now, I've found this really useful tool to summarize lots of JSON data.
Hope this helps!
from vj.
vj is mostly useful for viewing JSON log streams.
It doesn't do much for nested JSON (which may change in
the future but nesting makes the task a lot harder).
If you're a devop/admin who deals with noisy JSON logfiles
all day then vj can make that a bit less painful.
The best example is probably the one given in the README:
nc api.bitcoincharts.com 27007
vs
nc api.bitcoincharts.com 27007 | vj -c symbol -p price -s id
Note how the second output is color coded by symbol
,
prioritizes the price
column to appear at the left and
suppresses the id
.
We could also make the timestamp human readable
with a bit of jq, but I left that out here to keep it simple.
from vj.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vj.