I have published the Crystal version of Haye: An expressive string syntax to Array/Hash and Vice-Versa parser for Crystal. Based on the javascript version.
GitHub repo: https://github.com/krthr/haye.cr
Here is an example:
Usage
require "haye.cr"
Pipe -> Array
expression = 's'
parsed = Haye.fromPipe(expression) # Haye.fromPipe(expression, Haye::PresenterTypes::Array)
Output (Haye::Presenters::Node[]
)
[
#<Haye::Presenters::Node:0x7f11fd891e40
@name="required",
@args=[]
>,
#<Haye::Presenters::Node:0x7f11fd891de0
@name="email",
@args=["unique", "users"]
>
]
Pipe -> Hash
expression = 's'
parsed = Haye.fromPipe(expression, Haye::PresenterTypes::Hash)
Output (Hash
)
{
"required" => [],
"email" => ["unique", "users"]
}
I hope you enjoy!
Top comments (0)