Fork me on GitHub
#babashka
<
2020-03-11
>
shem14:03:09

I'm trying to parse the output of /usr/bin/swaymsg -t get_inputs . It produces a multi-line json string that according to a json linter is valid. I've had no success with /usr/bin/swaymsg -t get_inputs | bb '(json/parse-string *input*)' or with any combination of babashka options. That one produces the error clojure.lang.ExceptionInfo: java.lang.RuntimeException: Invalid token: : [at line 1, column 1]

borkdude14:03:00

@shem use cheshire.core in the same way you would on the JVM:

$ echo '{"a": 1,
"b": 2}' | bb '(json/parse-stream *in*)'
{"a" 1, "b" 2}

shem14:03:10

hey, that worked! thanks!

jeroenvandijk16:03:50

Nice! No rust?

borkdude16:03:10

I tried it from Rust, but I couldn't find a good example of how to call the lib from there and do some gnarly thread pointer thing. This helped: https://towardsdatascience.com/code-in-java-execute-as-c-921f5db45f20

jeroenvandijk16:03:49

I can believe it’s gnarly!

jeroenvandijk16:03:26

Is this a start for native libraries?

borkdude17:03:39

I don't think native libraries from the perspective of babashka is possible, since the interface (generated by native methods in Java) has to be known at compile time I think

borkdude17:03:48

so for the same reason you have to create these classes with native methods in Java, you can't just do that from pure dynamic Clojure

jeroenvandijk17:03:30

yeah makes sense

jeroenvandijk17:03:55

Btw, for those interested I’m using this code to do AWS requests in Graal https://github.com/adgoji/aws-api/blob/master/src/adgoji/cognitect/aws/signers.cljc#L150 It needs some examples, but if you really want to this could be a start. I’ve also used it from Clojurescript (not tested lately) (CC @holyjak I think you were interested)

❤️ 4
👀 4
Jakub Holý (HolyJak)18:03:21

An example would be very useful :)

jeroenvandijk18:03:50

I added the Sts example

jeroenvandijk18:03:23

It does need an http client like babashka curl (I used ring curl)

👍 4
jeroenvandijk12:03:56

I hope to have something easier to understand soonish

👍 4
borkdude17:03:50

maybe nice to mention in the #graalvm channel?

jeroenvandijk17:03:00

ah yeah good one