dynany

Dynamic JSON/YAML/CON mapping manipulation - extends Any
0.1.1 released
j8r/dynany
1
Julien Reichardt

Dynany

Dynamic JSON/YAML mapping manipulation - extends Any

Installation

Add this block to your application's shard.yml:

dependencies:
  clicr:
    github: j8r/dynany

Usage

This shard monkey patch JSON::Any and YAML::Any to extend them by adding this following methods, which are equivalent for those fround in Hash and Array.

The main difference is the argument, which accept an Enumerable which represents a path in the document.

The methods are: #[](path : Enunerable), #[]?(path : Enumerable, #[]=(path : Enumerable) and #.delete(path : Enumerable)

Example

require "dynany/json"

json = JSON.parse my_json
json[["hash", "array", 1]]  # => "value"
json.delete ["hash", "array", 1]
json[["hash", "array", 1]]? # => nil  

License

Copyright (c) 2018 Julien Reichardt - ISC License

dynany:
  github: j8r/dynany
  version: ~> 0.1.1
License ISC
Crystal none

Authors

Dependencies 0

Development Dependencies 0

Dependents 1

Last synced .
search fire star recently