Fork me on GitHub
#clojure-europe
<
2024-01-30
>
grav05:01:23

Morning :-)

grav08:01:43

From time to time I need to convert some edn config stuff into json. Is there some simple way to retain the order of the keys of such a static blop of EDN?

grav08:01:07

Could be as simple as an editor macro, I guess

grav08:01:02

Hm ... maybe I should just do that in Clojure ...

thomas09:01:37

isn't there a tool @U04V15CAJ wrote that can do this?

borkdude09:01:58

I guess you could use #CHB5Q2XUJ for this

👍 1
grav10:01:58

Phew, been a while since I used zippers 😅 Seems to be able to do what I want, although I had to add some functions for creating comma-nodes. At least this experiment could lead to a simple PR, if nothing else

reefersleep10:01:40

I had fun (and profit 🙂 ) with rewrite-clj on EOG, @U052XLL3A, just a testimonial 🙂

👌 1
borkdude10:01:55

you don't have to use zippers necessarily, I use rewrite-clj to work with the raw nodes a lot of the time

grav10:01:47

Yeah, I'm trying both approaces, but I'm having a hard time understanding how to use the nodes api for some reason - it will allow me to comma-separate nodes, but then the convertion back to strings goes haywire

borkdude10:01:06

I think I could also add an option to #C04QVMQ39LG to let you create ordered maps instead of regular hash-maps from map literals

borkdude10:01:13

this would be a lot easier than rewrite-clj

grav10:01:29

Well, of course if I can get others to solve my problem, that's easier 😄 But won't you have the same issue, if you have regular, unordered hash maps as an intermediate structure, @U04V15CAJ?

borkdude10:01:38

no:

user=> (e/parse-string "{:a 1}")
:elements [:a 1]
{:a 1}

borkdude10:01:52

it first parses the elements and then creates the hash-map, I could just make that configurable

borkdude10:01:10

similar for set I guess

👍 1
borkdude10:01:29

let me whip up a branch, then you can try if you want

grav10:01:44

sweet! I'd be happy to test it out!

borkdude10:01:57

$ clj -Sdeps '{:deps {borkdude/edamame {:git/url "" :git/sha "ce78f7b64381489c3feee7db40683cc5d0ec713d"} org.flatland/ordered {:mvn/version "1.15.11"}}}'
user=> (require '[edamame.core :as e])
nil
user=> (require '[flatland.ordered.map :as m])
nil
user=> (e/parse-string "{:a 1}" {:map m/ordered-map})
#ordered/map ([:a 1])

borkdude10:01:16

user=> (e/parse-string "{:x [{:a 1}]}" {:map m/ordered-map})
#ordered/map ([:x [#ordered/map ([:a 1])]])

borkdude10:01:32

with json:

user=> (j/write-str (e/parse-string "{:a 1 :b 2 :c 3 :d 4 :e 5 :f 6 :g 7 :h 8 :i 9 :j 10 :k 11 :l 12}" {:map m/ordered-map}))
"{\"a\":1,\"b\":2,\"c\":3,\"d\":4,\"e\":5,\"f\":6,\"g\":7,\"h\":8,\"i\":9,\"j\":10,\"k\":11,\"l\":12}"

grav10:01:23

Very nice! Works for me 🙂 TIL that clojure.data.json supports ordered maps

borkdude10:01:49

I think most tools just don't know the concrete type of the map, most core functions work against the interfaces behind it

👍 1
grav10:01:52

Well cheshire as well - I guess it's just that the ordered map implements iteration in a certain way?

borkdude10:01:03

ISeq, IAssociative, etc

👍 1
borkdude10:01:19

ok, I'll make a release, this is something I've wanted to support anyway and this felt like a good time :)

grav10:01:43

Great, thanks a lot for spending time on it 🙂

borkdude10:01:44

is there a need to make :set pluggable as well?

grav10:01:51

Generally I'd say yes. I've rarely used sets in config data, but they probably have their place

grav10:01:50

But for my use-case here, no

borkdude10:01:08

I'll just do it anyway

thomas12:01:27

can I get some brownie points for this? 😉

1
borkdude12:01:25

sure ;)

🙏 1
jasonbell09:01:16

Oh Durable Queue how I loved you. But on later Java versions……

SLF4J: See  for further details.
 Execution error (IllegalArgumentException) at durable_queue.Task/status_BANG_ (durable_queue.clj:176).
No matching method put found taking 2 args for class java.nio.DirectByteBuffer

🤯 2
thomas09:01:10

dang... and usually Java is quite good when it comes to backwards compatibility.

thomas09:01:26

(at least that is tell all the TS/JS people around me)

jasonbell09:01:30

I was trying to keep up with the issue comments in clj-commons as it’s there as an issue. Not clear if it was ever merged or not.

jasonbell10:01:06

Removed it for now, I can still call all my defmethods directly without any fuss, I just liked the queue there to handle the request load (not a problem I ever had 🙂 )

schmalz09:01:45

Morning all.

mdiin09:01:06

Morning

maleghast10:01:08

madainn mhath :flag-scotland:

otfrom12:01:58

Glad to see sunny Tayside back at it

😍 7
otfrom13:01:33

still does my head in that this was at roughly noon and that is looking due south (more or less). I wonder if I'll ever get used to being this far north.

simongray13:01:53

that beach is lit up

otfrom13:01:27

It was more than I could look at

Ed12:01:16

Morning

maleghast13:01:04

Yesterday evening - I was working from home and was able to capture this…

❤️ 8
wow 4
😍 2
reefersleep15:01:57

woweee. What beautiful colors, and foreground/background composition

☺️ 1
agigao15:01:06

Woah <3

☺️ 1
maleghast17:01:09

Thanks very much 🙂