00:01:04 | * | beholders_eye joined #nim |
00:16:17 | FromDiscord | <sirius_3x> how do I convert a tuple into a JSON object? |
00:17:34 | FromDiscord | <sirius_3x> (edit) "object?" => "object string? is there any built-in function for that?↵I already tried $ and % but they output something like this:↵"(name: \"Alice\", age: 30, isStudent: false, skills: [\"nim\", \"python\", \"cpp\"])"" |
00:19:15 | FromDiscord | <sirius_3x> sent a long message, see https://pasty.ee/ZRXGtRHK |
00:19:53 | FromDiscord | <sirius_3x> (edit) "long message," => "code paste," | "https://pasty.ee/QCoPlrRB" => "https://play.nim-lang.org/#pasty=OjJGXYWK" |
00:20:48 | FromDiscord | <Elegantbeef> `%(bleh).pretty` |
00:26:14 | FromDiscord | <sirius_3x> In reply to @Elegantbeef "`%(bleh).pretty`": ty for the quick response but %() doesnt seem to work on tuples, is that right? |
00:27:58 | FromDiscord | <sirius_3x> sent a code paste, see https://play.nim-lang.org/#pasty=OwdmBxSY |
00:28:11 | FromDiscord | <sirius_3x> (edit) "https://play.nim-lang.org/#pasty=QAVmtntA" => "https://play.nim-lang.org/#pasty=ldnjkAZy" |
00:28:44 | FromDiscord | <sirius_3x> With or without pretty |
00:29:54 | * | lucasta quit (Remote host closed the connection) |
00:30:31 | FromDiscord | <Elegantbeef> Guess you need `%` |
00:30:40 | FromDiscord | <Elegantbeef> I do not recall these asinine operators |
00:30:45 | FromDiscord | <sirius_3x> xD |
00:31:02 | FromDiscord | <sirius_3x> In reply to @Elegantbeef "Guess you need `%*`": still doesnt seem to work though :/ |
00:31:11 | FromDiscord | <sirius_3x> any third party library you can recommend? |
00:33:01 | FromDiscord | <sirius_3x> nvm think I mightve found one, ty for your help btw |
00:33:28 | FromDiscord | <Elegantbeef> You can just write the `%` for a tuple |
00:34:57 | FromDiscord | <sirius_3x> sent a code paste, see https://play.nim-lang.org/#pasty=xwHhRJul |
00:35:02 | FromDiscord | <sirius_3x> In reply to @Elegantbeef "You can just write": throws an error |
00:35:17 | FromDiscord | <sirius_3x> (edit) "https://play.nim-lang.org/#pasty=bJykBraO" => "https://play.nim-lang.org/#pasty=WSaapVAz" |
00:35:59 | FromDiscord | <sirius_3x> unless I convert it to a string first, via $, but that kinda defeats the purpose |
00:37:54 | FromDiscord | <Robyn [She/Her]> In reply to @sirius_3x "any third party library": jsony and sunny are good |
00:38:12 | FromDiscord | <Elegantbeef> Neither do pretty json though |
00:38:58 | FromDiscord | <Robyn [She/Her]> In reply to @Elegantbeef "Neither do pretty json": you can convert to a JsonNode |
00:39:28 | FromDiscord | <Elegantbeef> So bring in a dependency for no reason |
00:39:30 | FromDiscord | <Robyn [She/Her]> `fromJson(JsonNode, myTup.toJson())`, iirc |
00:39:35 | FromDiscord | <Robyn [She/Her]> In reply to @Elegantbeef "So bring in a": shrug |
00:42:54 | FromDiscord | <Elegantbeef> Heh not only bringing in a dependency but converting to a json string then parsing back to a json node to then store as a json string |
00:42:56 | FromDiscord | <Elegantbeef> Steps for days |
00:45:33 | * | beholders_eye quit (Read error: Connection reset by peer) |
00:46:23 | FromDiscord | <sirius_3x> sent a code paste, see https://play.nim-lang.org/#pasty=ApbMPzfE |
00:46:55 | FromDiscord | <sirius_3x> (edit) "https://play.nim-lang.org/#pasty=kJmujHtl" => "https://play.nim-lang.org/#pasty=vwvNpVHH" |
00:47:12 | FromDiscord | <Elegantbeef> I jusut showed you how |
00:47:15 | FromDiscord | <Elegantbeef> just\ |
00:47:25 | FromDiscord | <Elegantbeef> Bridge moment |
00:47:37 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#pasty=CEJqVMSr |
00:47:44 | FromDiscord | <Elegantbeef> What a bridge |
00:51:22 | * | beholders_eye joined #nim |
00:52:14 | FromDiscord | <sirius_3x> Thanks, that code does actually work! However, if I omit the proc that you copied from stdlib, it doesnt work. Idk why. I thought this function is part of the std library? Doesn't it get imported for some reason?↵The other thing is, your original answer actually had the % outside of the brackets, thats why it also wouldnt work |
00:52:36 | FromDiscord | <Elegantbeef> The stdlib's `%` for whatever reason does not work with tuples |
00:52:51 | FromDiscord | <sirius_3x> In reply to @Elegantbeef "The stdlib's `%` for": so you did actually just write a custom function for that lmao |
00:53:08 | FromDiscord | <Elegantbeef> Well I stole the stdlib's object code |
00:53:11 | FromDiscord | <Elegantbeef> Since it's the same thing |
00:53:54 | FromDiscord | <Elegantbeef> Operators bind to the entire expression not the first part |
00:54:10 | FromDiscord | <Elegantbeef> so `$bleh[0].meh.huh` is `$(bleh[0].meh.huh)` |
00:54:10 | FromDiscord | <Robyn [She/Her]> In reply to @Elegantbeef "Well I stole the": using fieldPairs on a named tuple? |
00:54:24 | FromDiscord | <Elegantbeef> You can use it on all tuples |
00:54:31 | FromDiscord | <sirius_3x> In reply to @Elegantbeef "Well I stole the": oh true, smart actually, lol↵thanks again |
00:54:32 | FromDiscord | <Elegantbeef> Doesn't matter if it's named or unnamed |
00:54:38 | FromDiscord | <Elegantbeef> If it's unnamed you get `Field0`.... |
00:54:42 | FromDiscord | <Robyn [She/Her]> In reply to @Elegantbeef "You can use it": oh? |
00:54:47 | FromDiscord | <Robyn [She/Her]> In reply to @Elegantbeef "If it's unnamed you": damn, neat |
00:56:50 | * | beholders_eye quit (Ping timeout: 252 seconds) |
01:00:06 | * | albe4 joined #nim |
01:01:37 | FromDiscord | <nervecenter> In reply to @sirius_3x "are you sure? Because": If there's a way to convert a tuple to a seq first that might be a good middle ground |
01:02:16 | FromDiscord | <Elegantbeef> tuple to a seq.... that only works if the tuple is singly typed |
01:02:18 | * | albe quit (Ping timeout: 244 seconds) |
01:02:19 | * | albe4 is now known as albe |
01:03:52 | FromDiscord | <sirius_3x> In reply to @nervecenter "If there's a way": Elegantbeef also already kindly provided a function that converts any tuple to a JSONobject |
01:04:50 | FromDiscord | <nervecenter> In reply to @Elegantbeef "tuple to a seq....": right, dang forgot about that |
01:05:28 | FromDiscord | <nervecenter> yeah beef's proc is exactly what I would do given the constraints |
01:05:47 | FromDiscord | <nervecenter> iterate over the values and drop them in a new JArray |
01:05:52 | FromDiscord | <Elegantbeef> It's what the stdlib should do `T: object | tuple` instead of just `T: object` |
01:06:10 | FromDiscord | <Elegantbeef> You also misread their goal nerve |
01:06:17 | FromDiscord | <Elegantbeef> They want to have a prettified json object |
01:06:48 | FromDiscord | <nervecenter> Oh I see it's a named tuple |
01:06:55 | FromDiscord | <nervecenter> please ignore me I am not thinking atm |
01:15:34 | FromDiscord | <sirius_3x> In reply to @Elegantbeef "It's what the stdlib": beef, are you creating a pull request for that? cause if not then I will |
01:35:46 | FromDiscord | <sirius_3x> In reply to @Elegantbeef "It's what the stdlib": nvm I just created one and made sure to credit you in the description, in case thats important to you. hope you dont mind. |
03:16:30 | * | xutaxkamay quit (Quit: ZNC 1.8.2+deb3.1+deb12u1 - https://znc.in) |
03:16:40 | * | xutaxkamay_ joined #nim |
03:17:29 | * | xutaxkamay_ is now known as xutaxkamay |
03:53:40 | * | SchweinD1 quit (Quit: WeeChat 4.5.0-dev) |
03:54:24 | * | SchweinDeBurg joined #nim |
05:10:09 | * | albe quit (Quit: The Lounge - https://thelounge.chat) |
05:10:32 | * | albe joined #nim |
06:10:32 | * | coldfeet joined #nim |
06:36:01 | * | xet7 quit (Ping timeout: 272 seconds) |
07:00:11 | * | ntat joined #nim |