ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
bastienleonard has quit [Ping timeout: 244 seconds]
notzmv has quit [Ping timeout: 272 seconds]
sagax has joined #crystal-lang
notzmv has joined #crystal-lang
<FromGitter> <galvertez> anybody know how to use `JSON::Builder` to intentionally build invalid json? i have a spec that requires invalid json and nothing i've tried works. would rather prefer to use the builder instead of just an ad-hoc string if possible
<FromGitter> <galvertez> that feel when `JSON::Builder` is too good and won't let you do a bad
sagax has quit [Quit: Konversation terminated!]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 272 seconds]
Sankalp has quit [Ping timeout: 240 seconds]
ur5us has joined #crystal-lang
<FromGitter> <Dan-Do> > https://carc.in/#/r/dfnm something like this i think ⏎ ⏎ it failed with complicate structure https://carc.in/#/r/dfql
Sankalp has joined #crystal-lang
ur5us has quit [Ping timeout: 240 seconds]
Flipez has quit [Changing host]
Flipez has joined #crystal-lang
ur5us has joined #crystal-lang
hightower2 has joined #crystal-lang
<FromGitter> <Daniel-Worrall> How invalid? Do you have an example
ur5us has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> @galvertez https://play.crystal-lang.org/#/r/dfru
<FromGitter> <Blacksmoke16> the trick is not using the block versions of the methods
rymiel has quit [Quit: quit]
rymiel has joined #crystal-lang
<FromGitter> <moe:busyloop.net> for a spec i would rather embed invalid json as a string
<FromGitter> <moe:busyloop.net> (easier to understand what's going on for older self or next-maintainer)
Stephie- is now known as Stephie
_ht has joined #crystal-lang
<FromGitter> <galvertez> you might be right about that @moe:busyloop.net
<FromGitter> <galvertez> just seems wonky because of how much of the API using a string bypasses
<FromGitter> <galvertez> that being said, if i did just use a straight up string, the aspect in question would still satisfy the spec
<FromGitter> <galvertez> but the test case is literally `it "handles an rpc call with invalid JSON" do` lol so i just made a helper class w/ a method `invalid_json`
<FromGitter> <Blacksmoke16> you def can make invalid json with the builder, checkout the playground link
<FromGitter> <galvertez> ya i saw - that should do everythign i need
<FromGitter> <galvertez> thank you :D
<FromGitter> <galvertez> i did something similar, except that i did it inside a class and defined `to_json(builder : JSON::Builder)` and it doesn't like that. i assume because of implicit usage of block versions of the methods
<FromGitter> <galvertez> when calling `to_json` on the intance
<FromGitter> <galvertez> sorry for a screenshot, but it's from my playground server on my homelab. i think i'm putting too much thought into this either way. i think moe is right. a string should suffice for this particular spec
<FromGitter> <galvertez> sure do, section 7 "Examples" https://www.jsonrpc.org/specification#examples; 6th example
<FromGitter> <Blacksmoke16> well i mean in this case its not wrong
<FromGitter> <Blacksmoke16> just never call `end_object` and call it a day
<FromGitter> <Blacksmoke16> and will generate like `{"key":"value"` which is still invalid
<FromGitter> <Blacksmoke16> unless you need it to be a specific form of invalid?
<FromGitter> <galvertez> well i was hoping to implement https://www.jsonrpc.org/specification#examples exactly as seen, or as close to it as possible
<FromGitter> <galvertez> doesn't matter if it's 1 char off or 1000, invalid json is invalid json.
<FromGitter> <galvertez> so whether i `end_array` or just never close the object. it's still invalid
<FromGitter> <galvertez> good enough for rock'n'roll
<FromGitter> <Blacksmoke16> yea the builder is somewhat smart to prevent missing `{` and `]`, but shouldn't really matter
<FromGitter> <Blacksmoke16> if you really wanted could prob just redefine `to_json : String` and return a scalar sting
<FromGitter> <Blacksmoke16> string
Elouin has quit [Read error: Connection reset by peer]
Elouin has joined #crystal-lang
<FromGitter> <galvertez> ya i actually wound up doing it w/ a plain io after i first posted just to get past it
<FromGitter> <galvertez> also i gotta say. i just the other day got the playground up and running and i really like it a lot. haven't tried out the interpreter yet but the playground is really cool and does most of what i'd want out of an interpreter
analogsalad has joined #crystal-lang
_ht has quit [Remote host closed the connection]
notzmv has quit [Ping timeout: 276 seconds]
analogsalad has quit [Quit: bye]
jmdaemon has joined #crystal-lang