Comments (3)
Thanks for asking! This is an interesting problem, as the java.util.ArrayList
doesn't trigger any of the "it must be one of these, print it this way", and just falls through into printing as a string. I'm sure that there are other Java types that will end up the same way. I'm tentatively open to the idea of some sort of class or type based transformation, although I'm not clear on where to put it. One option is for the things that don't show up as something else, another is to do it prior to the tests for what something is -- which is what you are implying, I think.
I'll give this some thought and see what I can figure out. If you happen to have any other examples of real-world Java classes that are getting the same (.toString ...)
treatment, it would be interesting to have more than one example to experiment with and to write tests for. Thanks!
from zprint.
Maybe this is a case for clojure.datafy?
something -datafy-> data -zprint-> formatted string
feels like a good way to separate the concerns.
from zprint.
This is now implemented in 1.2.9
.
There is a new option map key to transform random Java classes into other, more manageable data types: :modify-sexpr-by-type
.
I wrote up a whole big thing in the reference manual about how this works (using your example data above). Search the reference manual for :modify-sexpr-by-type
and hopefully that will explain how to do what you want. Let me know if it isn't clear.
from zprint.
Related Issues (20)
- Adding Better Clojure Formatting from Tonsky HOT 8
- Keep unchanged kondo directives HOT 3
- Consider segregating justification domains between blank lines
- Reflection and auto-box warnings - wrt GraalVM HOT 4
- Enforce a space between comment character and comment HOT 1
- Sorting :require dependencies alphabetically. HOT 24
- Errors encountered when applying multiple styles may not be reported HOT 1
- Meta formatting HOT 4
- Making exceptions for `{:force-nl? true}` in maps when destructuring HOT 5
- Different output of tagged literals in library vs shell HOT 4
- Function to format a whole top-level file that takes code instead of a string? HOT 6
- formatting assoc function similar to cursive HOT 3
- Using `:indent-only?` when formatting Clojure structures doesn't work.
- Consider extending `:hiccup` style to handle reagent's `:>` shorthand for `reagent/adapt-react-class` HOT 1
- Make minimum number of map entries `lift-ns?` requires configurable HOT 2
- Zprints escapes already escaped newlines HOT 3
- Sort require does not apply depending on order in style HOT 6
- Deprecate `:return-altered-zipper` and write documentation for `:new-zloc` approach.
- Align `:arg1-pair` pairs with first arg HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zprint.