Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nested_hash

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nested_hash

  • 0.2.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

NestedHash

NestedHash is a Hash converter. It will created a simple, key encoded hash, in to a nested hash. For example, the hash:

{
  "name" => "guillermo",
  "properties.age" => 29,
  "properties.sex" => "male",
  "parents.1" => "ramon",
  "parents.2" => "gloria"
}

will be converted into the hash

{
  "name" => "guillermo",
  "properties" => {
    "age" => 29,
    "sex" => "male"
  },
  "parents" => [ "ramon", "gloria" ]
}

Usage

require 'nested_hash'

my_normal_hash = {
  "name" => "guillermo",
  "properties.age" => 29,
  "properties.sex" => "male",
  "parents.1" => "ramon",
  "parents.2" => "gloria"
}

my_new_hash = NestedHash.new(my_normal_hash)
my_new_hash # => {"name"=>"guillermo", "properties"=>{"age"=>29, "sex"=>"male"}, "parents"=>["ramon", "gloria"]}

NestedHash inherits from Hash, so you can use it as a normal hash.

Installation

$ gem install nested_hash

Motivations

The reason for creating this ruby gem is to convert Excel files to json files. With the rubygems roo you already can get the rows into a one level hash (colum title as a key). This complement help to create more difficult structures with the same excel file.

License

Mit

FAQs

Package last updated on 04 Jun 2012

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc