Skip to content
Pinter Computing

Knowledge Base for IT Professionals, Teachers, and Astronauts

Pinter Computing

Knowledge Base for IT Professionals, Teachers, and Astronauts

  • Home
  • Programming
  • DevOps
  • Project Management
  • Software and Hardware
  • Miscellaneous
  • Egyebek
  • About
  • Experience
  • Education
  • Contact
  • Home
  • Programming
  • DevOps
  • Project Management
  • Software and Hardware
  • Miscellaneous
  • Egyebek
  • About
  • Experience
  • Education
  • Contact
Close

Search

Home/DevOps/Chef/Extract data from JSON with Ruby
ChefCloud computingDevOps

Extract data from JSON with Ruby

By Laszlo Pinter
July 13, 2016 1 Min Read
0

Chef uses Ruby as the scripting language. If you need to extract data out from a JSON string you can use the following script


# Save the JSON values
instance_data_drive_config = '{"size":"500","type":"io1","iops":"15000"}'

# Parse the JSON to a hash
data = JSON.parse(instance_data_drive_config)

# Declare the variables
size = ''
type = ''
iops = ''

# Iterate through the hash
data.each do |child|
case child[0]
when 'size'
size = child[1]
when 'type'
type = child[1]
when 'iops'
iops = child[1]
end
end

# Display the result
puts "size=#{size}"
puts "type=#{type}"
puts "iops=#{iops}"

The output is
size=500
type=io1
iops=15000

Tags:

ChefRuby
Author

Laszlo Pinter

Follow Me
Other Articles
Previous

DJI Phantom 4 firmware update stops at 92%

Next

DevOps interview questions

No Comment! Be the first one.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Last Changes

  • Building Scrappy, the AI hardware robot November 10, 2026
  • Scrappy, the AI hardware robot – the face - display November 10, 2026
  • Scrappy, the AI hardware robot – the mouth - amp and speaker November 10, 2026
  • Scrappy, the AI hardware robot - the ears - microphone November 10, 2026
  • LM Studio November 8, 2026

Tags

.NET .NETcore 3Dprinting AI AWS C# Chef cloud DevOps Docker EntityFramework Games Git Go iOS iPad iPhone iPod Java Kubernetes Linux MacOSX MSSQL MVC MySql Node.js Packer PowerShell Python RDS Ruby security Splunk storage TeamCity Terraform TestKitchen Tomcat Ubuntu Vagrant VirtualBox VisualStudio Windows WordPress Xcode

Recent Comments

  • Laszlo Pinter on Turn off the built in touchpad when a mouse is attached
  • Kenneth Bush on Turn off the built in touchpad when a mouse is attached
  • Zengei László on MyHeritage családfa exportálása és küldése emailben
  • Raúl Castillo on DynDns update error
  • MICHAEL on Windows Media Player 12 cannot find the album information

–

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Copyright 2026 — Pinter Computing. All rights reserved.