In the UK we have a petition system where anyone can set up a petition and if it reaches 100K names, the subject gets debated in Parliament. Its an idea that gets misused by various lobby groups and there are often news stories where some political idea gets forced into debate by a group who can’t accept the status quo.
Anyway, enough politics, the interesting part is getting to the numbers. Take the last big petition – all about Brexit. Each petition has a JSON page where all those lovely numbers are easy to see – but while JSON is easier to read than XML, its no Infographic!
So how are we going to read this? Powershell!
Its only two lines, but its very good.
$datapetition = Invoke-WebRequest -uri “https://petition.parliament.uk/petitions/131215.json” | ConvertFrom-Json
The first line reads the data, and after the pipe, the variable becomes a Powershell object. The second line grabs the attribute we need. All you need to do is to read it.
$datapetition.data.attributes – this is where the magic is!
Unlike other site that will spoon feed you, I am not adding any more – just experiment and see all the data show up!