Popularity
6.4
Growing
Activity
5.1
-
35
5
1
Programming language: Crystal
License: MIT License
Tags:
Misc
Latest version: v0.2.3
any_hash.cr alternatives and similar shards
Based on the "Misc" category.
Alternatively, view any_hash.cr alternatives based on common mentions on social networks and blogs.
-
sentry
Build/Runs your crystal application, watches files, and rebuilds/restarts app on file changes -
immutable
Thread-safe, persistent, immutable collections for the Crystal language -
crystagiri
An Html parser library for Crystal (like Nokogiri for Ruby) -
crz
Functional programming library for https://github.com/crystal-lang/crystal -
crystal-web-framework-stars
โญ๏ธ Web frameworks for Crystal, most starred on Github -
crystal-futures
Future type implementation for Crystal language -
cron_scheduler
Simple job scheduler with crontab patterns for Crystal Language. -
inflector.cr
Inflector shard for Crystal. A port of ActiveSupport::Inflector -
aasm.cr
:arrows_clockwise: Easy to use finite state machine for Crystal classes -
kreal
Kreal is a model sharing & RPC library built on and works with Kemal seamlessly. -
retriable.cr
Retriable.cr is a simple DSL to retry failed code blocks -
ulid
Universally Unique Lexicographically Sortable Identifier (ULID) in Crystal -
CrSerializer
Extensible annotation based serialization/deserialization library -
circuit_breaker
Implementation of the circuit breaker pattern in crystal -
burocracia.cr
๐ Zero-dependency Crystal shard to validate, generate and format Brazilian burocracias (CPF, CNPJ, CEP) -
wikicr
Wiki in crystal, using Markdown and Git, inspired by dokuwiki. Last features to build are pretty hard, if you have some time to help... :) -
m3u8
Generate and parse m3u8 playlists for HTTP Live Streaming (HLS) in Crystal. -
message_verifier.cr
Rails compatible MessageVerifier for Crystal-lang apps -
defined
This shard provides facilities for checking whether a constant exists at compile time, and for a variety of different conditional compilation options. Code can be conditionally compiled based on the existence of a constant, version number constraints, or whether an environment variable is set truthy or not.
InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
Promo
www.influxdata.com
Do you think we are missing an alternative of any_hash.cr or a related project?
README
any_hash.cr
AnyHash is a library created to help with traversing and manipulation of
nested Hash
structures.
Installation
Add this to your application's shard.yml
:
dependencies:
any_hash:
github: sija/any_hash.cr
Usage
require "any_hash"
Using AnyHash::JSON
AnyHash::JSON
is ready-to-use JSON friendly version of Hash
.
It takes care of casting immutable types to their mutable equivalents:
Tuple
โArray
NamedTuple
โHash
Traversing
# possibly coming from `**options` argument, could be a `Hash` too
options = {
status: :published,
tags: {"crystal", "ruby", "sweet"},
context: {
user: {
id: 123,
}
}
}
# convert any Hash or NamedTuple to `AnyHash::JSON` via `Object#to_any_json`
options = options.to_any_json
# return underlying `Hash`
options.to_h # => {:status => :published, :tags => ["crystal", "ruby", "sweet"], :context => {:user => {:id => 123}}}
# access direct descendant value
options[:status] # => :published
options[:status].class # => Symbol
typeof(options[:status]) # => (Array(AnyHash::JSONTypes::Value) | Bool | Float32 | Float64 | Hash(String | Symbol, AnyHash::JSONTypes::Value) | Int16 | Int32 | Int64 | Int8 | Set(AnyHash::JSONTypes::Value) | String | Symbol | Time | UInt16 | UInt32 | UInt64 | UInt8 | Nil)
# access nested structures with key path
options[:context, :user, :id] # => 123
# `#[]` is an alias for `#dig`, same for `#[]?` -> `#dig?`
options[:context, :system, :os]? # => nil
options.dig?(:context, :system, :os) # => nil
Manipulation
# `#[]=` works with single keys and key paths
options[:featured] = true
options[:context, :user, :role] = :editor
defaults = {
difficulty: :easy,
status: :draft,
featured: false,
tags: [] of String,
context: {} of Symbol => String
}
# merge defaults in-place
options.reverse_merge!(defaults)
# or return a copy with applied changes
settings = options.reverse_merge(defaults)
# merge nested structures
options.merge! context: {user: {email: "[email protected]"}}
# or single values
options.merge! id: 420
Defining your own class
AnyHash.define_new klass: :DegreesOfLogic,
key: Symbol | String,
value: Bool
DegreesOfLogic.new({ there: { are: { many: { truths: true, or: false }}}})
Development
Run specs with:
crystal spec
Contributing
- Fork it ( https://github.com/sija/any_hash.cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- sija Sijawusz Pur Rahnama - creator, maintainer