<miketheman>
BlaXpirit: I was trying to get the json (a response from a web call) to get turned into a Hash, but couldn't - so I had to end up building structs and doing the `from_json` approach
luislavena has quit [Ping timeout: 276 seconds]
<miketheman>
BlaXpirit: might you have an example a json to hash?
<plukevdh>
i was going to ask about that at some point
<plukevdh>
+1
<plukevdh>
is it possible to have a JSON::Mapping that has an entry of sort of unknown type?
<plukevdh>
I have a JSON blob being returned that has a field `config`
<plukevdh>
which is a hash with variable types inside of it
<plukevdh>
"config": {
<plukevdh>
"whitelist": [
<plukevdh>
"docs"
<plukevdh>
]
<plukevdh>
},
<plukevdh>
"config": {
<plukevdh>
"hide_credentials": true
<plukevdh>
},
<asterite>
Try using JSON::Any as the mapping type
<plukevdh>
of the hash or at the root? so { type: Hash(String, JSON::Any) } or { type: JSON::Any } ?
<plukevdh>
the latter appears to work
<plukevdh>
as dies the former? interesting...
<plukevdh>
*does
trapped has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<asterite>
The first one makes sure it's a hash (object) with any values inside it, the second makes it so that the value could be a number, string, object, but not necessarily an object (I guess Hash(String, JSON::Any) makes more sense here)
Excureo has quit [Remote host closed the connection]
Excureo has joined #crystal-lang
alsm has quit [Ping timeout: 250 seconds]
plukevdh has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
A124 has quit [Ping timeout: 240 seconds]
plukevdh has joined #crystal-lang
luislavena has quit [Ping timeout: 276 seconds]
A124 has joined #crystal-lang
Guest74012 is now known as Cyrus
Cyrus has joined #crystal-lang
Cyrus has quit [Changing host]
r00takaspin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
luislavena has joined #crystal-lang
trapped has joined #crystal-lang
luislavena has quit [Quit: Leaving]
pawnbox_ has quit [Remote host closed the connection]
marcosdsanchez has quit [Read error: Connection reset by peer]
marcosdsanchez has joined #crystal-lang
alsm has joined #crystal-lang
pawnbox has joined #crystal-lang
r00takaspin has joined #crystal-lang
pawnbox has quit [Ping timeout: 244 seconds]
ssvb has quit [Quit: Leaving]
<crystal-gh>
[crystal] AlexWayfer opened pull request #2224: Added random methods with max of Float and range of Floats (master...rand_float_range) https://git.io/v2l0u
<plukevdh>
So I've opened up a couple issues now (or almost opened) where Crystal is missing a method from the Ruby stdlib
<plukevdh>
but in most cases, Ruby has another method that does the same thing
<plukevdh>
example inject vs. reduce
alsm has quit [Ping timeout: 276 seconds]
<plukevdh>
is Crystal attempting to keep those method dups to a minimum? there are just enough a deviations from Ruby stdlib that catch me unawares quite frequently
<plukevdh>
and I start out implementing some of those methods then find out it was a similar or identical method or alias...
<plukevdh>
so more a question of design goals
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
Philpax has joined #crystal-lang
Philpax has quit [Ping timeout: 240 seconds]
<Kilo`byte>
plukevdh: well, it kinda makes sense
<Kilo`byte>
when you don't have to care about compatibility (all code will need porting anyways) you can start off cleanly
<Kilo`byte>
ruby keeps most those methods for compatibility
<Kilo`byte>
although the name reduce surprised me there :P i'd have expected fold