
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
Json2 transforms a Json file into a Csv one.
Add this line to your application's Gemfile:
gem 'json2'
And then execute:
$ bundle
Or install it yourself as:
$ gem install json2
Given the following Json file:
[
{
"color": "red",
"value": "#f00"
},
{
"color": "green",
"value": "#0f0"
},
{
"color": "blue",
"value": "#00f"
}
]
You could obtain a Csv with a header like that:
$ json2 colors-array.json
color,value
red,#f00
green,#0f0
blue,#00f
With this simpler kind of Json:
{
"red":"#f00",
"green":"#0f0",
"blue":"#00f"
}
Here is the resulting Csv:
$ json2 colors3.json
red,green,blue
#f00,#0f0,#00f
Take a slightly more complicated Json file:
{
"id": "0001",
"type": "donut",
"batters":
{
"batter":
[
{ "id": "1001", "type": "Regular" },
{ "id": "1002", "type": "Chocolate" },
{ "id": "1003", "type": "Blueberry" },
{ "id": "1004", "type": "Devil's Food" }
]
},
"topping":
[
{ "id": "5001", "type": "None" },
{ "id": "5002", "type": "Glazed" },
{ "id": "5005", "type": "Sugar" }
]
}
Say you want to extract the batter stuff. Use the --path switch:
$ json2 --path='batters.batter' products.json
id,type
1001,Regular
1002,Chocolate
1003,Blueberry
1004,Devil's Food
Json don't always map very well with Csv. Sometimes there is simply no header information inside the Json:
{
"Nom du parti": {
"Abstention": [
"Jean"
],
"Non-votant": [],
"Contre": [
"Alice",
"Georges"
],
"Pour": [
"Julie"
]
}
}
In this case, you can use the --without-header switch:
$ json2 --without-header votes.json
Nom du parti,Abstention,Jean
Nom du parti,Non-votant,
Nom du parti,Contre,Alice
Nom du parti,Contre,Georges
Nom du parti,Pour,Julie
git checkout -b my-new-feature)git commit -am 'Add some feature')git push origin my-new-feature)MIT
Feel free to email Xavier Nayrac with any questions, or contact me on twitter.
FAQs
Unknown package
We found that json2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.