Fork me on GitHub
#beginners
<
2016-10-07
>
donaldball01:10:55

By choosing a specific conversion strategy. You could do just that in clojure with the aforementioned libraries if you like.

seancorfield02:10:53

It’s also worth bearing in mind that JSON / EDN / Clojure data structures are very, very similar (asides from richer types in EDN / Clojure — but their structure is very similar). That is not true for XML. The JSON-java library just happens to pick an (opinionated) option for you that you can’t control. Great if you like its choice — sucks if you don’t. The various XML parsing libraries in Clojure all produce different structures and some of them provide a degree of control over what that structure is. So reading XML -> Clojure data structures gives you the most freedom and the most choice (and then Clojure to JSON is "trivial" and near 1:1). @josh_tackett /cc @donaldball

codxse03:10:53

Hi, I don't know if this place is right place to ask this question. So, my question, are there any Clojure function that doesn't work on ClojureScript function??

seancorfield03:10:45

Probably the concurrency stuff? pmap, agent…? I’d have to go digging in the docs.

seancorfield03:10:42

cljs.user=> (map inc [1 2 3 4])
(2 3 4 5)
cljs.user=> (pmap inc [1 2 3 4])
ERROR - undefined is not an object (evaluating 'cljs.user.pmap.call')
cljs.user=> (def q (agent nil))
ERROR - undefined is not an object (evaluating 'cljs.user.agent.call')

josh_tackett14:10:38

@seancorfield The data structure that clojure.data.xml produces is completely unusable...

josh_tackett14:10:42

its a complete mess

val_waeselynck14:10:45

@josh_tackett the mess is inherent to XML (which is partly why people have been moving away from XML to JSON), you can't really blame clojure.data.xml for that IMO

josh_tackett14:10:56

@val_waeselynck The question remains, what is the best way to parse it then? because clojure.data.xml is no the way to do it

val_waeselynck14:10:49

why not? Sure, you have to do some post-processing afterwards, but Clojure really isn't the worst language to use to transform data structures

val_waeselynck14:10:32

note that you can use things like clojure.data.zip to traverse the data structure

josh_tackett15:10:09

@val_waeselynck the data structure that is returned is soooooo deeply nested that it is very difficult to traverse

donaldball15:10:53

Some find spectre useful for working with deeply nested data structures

plexus19:10:07

@josh_tackett the clojure.data.xml format is the most suitable representation for processing you'll find I think. The alternative is hiccup syntax, which is great for writing but terrible for processing

plexus19:10:38

have you looked at enlive? it lets you manipulate html/xml using CSS like selectors

josh_tackett20:10:50

@plexus Its ok I just put in the hours and destructured it