bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 250 seconds]
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
ponga has quit []
tomchapin has joined #crystal-lang
theduke has quit [Quit: Leaving]
bjz has joined #crystal-lang
theduke has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
<adam12>
Without send, is there another way I could call a method on an object where that method name is defined in some variable?
<adam12>
I think a `case` statement will work here instead of `send`
tomchapin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
triangles has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
tomchapin has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 256 seconds]
tomchapin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 264 seconds]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 276 seconds]
Philpax_ has quit [Quit: Leaving]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
tomchapin has joined #crystal-lang
tomchapin has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
tomchapin has joined #crystal-lang
tomchapin has quit [Client Quit]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
tomchapin has joined #crystal-lang
<jhass>
theduke: a bit, nothing public and suspended for the moment
<jhass>
adam12: yes, the usual way to solve send usecases is to use a case statement, possibly generated by a macro
Philpax has joined #crystal-lang
trapped has joined #crystal-lang
pawnbox has quit [Ping timeout: 240 seconds]
pawnbox has joined #crystal-lang
praveen has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
<jokke>
hello
<jokke>
is it possible to somehow extract parts of a json as strings from an io with the pull parser for later use?
<jokke>
my use case is this: i'm writing a parser for json-rpc. Every request has a method. depending on this method i want to instanciate the corresponding request class. each request class is responsible for parsing the params of the request (if any)
<jokke>
the problem is: i could get a json like this {..., "params": {"foo": "bar"}, "method": "foobar"}
<jokke>
in this case i wouldn't know the method at the time i should be parsing the params
<jokke>
so i'm looking for a way to store the value of params as a string while skipping it for the time being
<jokke>
after i've parsed the whole request object i could then pass the string to the request class instance corresponding to the method which would then parse the string
<jokke>
i hope i made clear enough what i'm after
kulelu88 has joined #crystal-lang
praveen has quit [Remote host closed the connection]
praveen has joined #crystal-lang
<jhass>
jokke: I'd parse twice
<jhass>
first with a generic mapping that ignores the changing parts
<jokke>
jhass: i can't since it's an io
<jhass>
read it into a string first?
<jokke>
it's a socket which remains open
<jokke>
i need to read 1 json object at a time
<jokke>
so i need the pull parser to tell me when i've read an object
<jokke>
maybe it'd make sense to add some alternative skip method to the pull parser which would return the string of the skipped entity
<ytti>
i'd love better docs how to turn JSON or YAML into crysytal structure
<ytti>
the example in docs for YAML makes it non-obvious to me
<ytti>
it works for simple case, but i don't get how to describe more common case, other than force type when evaluating
<ytti>
i'd like to force type when loading
<ytti>
i.e. fully describe whole JSON/YAML format, then populate the object
<jokke>
ytti: look into YAML.mapping and JSON.mapping
<jokke>
it's quite well documentde
<jokke>
*documented
<ytti>
jokke, the mapping in URL i pasted, does not make it clearly me, what happens if the key contains a hash
<jokke>
oh ok. in that case you need to pass a converter
kulelu88 has quit [Quit: Leaving]
<jokke>
that is basically just a class which needs to implement the class method from_yaml. OR you just define a YAML.mapping for that class (it will add the from_yaml method for you)
<jhass>
jokke: you probably won't convince Ary of it, I'm not sure yet
<jokke>
jhass: mmh
<jokke>
i'd say it's a pretty common use case though
<jokke>
i'd also think a JSON.mapping type :raw or something similar would be helpful (and would make use of the alternative skip method)
<jokke>
but JSON.mapping is still not extendable by inheritage so i guess it's not that important