Comments (18)
Is there an obvious way to implement this with the existing cheshire design?
Not that I can immediately think of, I will have to experiment to see if there already is.
Is this a feature that would be welcome for cheshire if I implemented it?
Yes, definitely would be nice as long as it does not negatively affect performance.
from cheshire.
This has been a big pain point for me as well.
One option I just thought of is to have another option that can be passed of a :fallback-encoder
-- an encoder function that gets used whenever the JsonGenerationException
would otherwise be thrown. Presumably that wouldn't be a big perf problem (at least for people not using it) since it's only a code change in an otherwise-exceptional codepath.
For my use cases I think the fallback encoder would pretty much always just use str
, so we could also consider adding a feature that just does that, or at least an easier way to opt into that than an actual encoder fn.
from cheshire.
Though now that I look through the implementation I remember that options are passed around as first-class args, and so having an extra option means expanding the signatures everywhere :/
from cheshire.
If the signature thing is a big perf deal, maybe an internal dynamic var that gets set once at the top level would be an alternative.
from cheshire.
I remember that options are passed around as first-class args, and so having an extra option means expanding the signatures everywhere :/
I'd need to check the performance hit for it, but if it's not too much, a breaking change (Cheshire 6.x) to switch to a map of options would be better for future development.
from cheshire.
I'll see if I can quickly make a branch with the options-map change.
from cheshire.
Okay, remember not to use destructuring as that (unfortunately) causes a big performance hit.
from cheshire.
do you just mean destructuring when you don't actually need all the keys? When I macroexpand a {:keys [foo bar]}
destructuring the only extra thing I see is a (seq? m)
check, is that the bad part?
from cheshire.
I haven't dug into why it's slower yet, only that it was slower in benchmarks (heck, maybe Clojure has caught up and it's better in recent versions?), so it would be good to test and see.
from cheshire.
okay; it ought to be identical to the macroexpanded code, but regardless I will leave it out so we don't have to wonder
from cheshire.
Okay I have some code here that seems to work except for some bug in the generate-seq code that I don't have time to chase down at the moment. Hopefully the non-seq code is correct and adequate for perf tests.
from cheshire.
(bug indicated by the one test failure)
from cheshire.
Okay I have some code here that seems to work
Great, thanks! No guarantees for when I will be able to look as my wife just had a baby and I am short on sleep/free-time, but I will try to take a look whenever I can! :)
from cheshire.
babies babies babies babies babies babies babies babies babies babies babies babies!
from cheshire.
@gfredericks I finally had a second to check out your branch. Performance-wise it looks good to me, would you be able to open a PR for moving to it?
from cheshire.
Will do
from cheshire.
In terms of an API for extending via opts, the code used in greglook/puget#23 will probably be relevant.
from cheshire.
Any news on this? Looking also forward to this, config similar like the edn / transit readers?
from cheshire.
Related Issues (20)
- Always update to latest version of Jackson, when available
- Any way to not escape the quotes HOT 2
- Suggestion: prove equivalence with clojure.data.json HOT 6
- Add support for capturing source position/locations when parsing HOT 2
- Allow key-fn like hook for value HOT 2
- Converting nested fields from java objects to clojure types doesnot work
- Custom conversion when parsing?
- `parsed-smile-seq` actually parses JSON
- Run tests against JSONTestSuite
- Resulting Array from parse not processed lazily HOT 1
- :key-fn no longer works in generate-string? HOT 1
- Using the Ubuntu Cheshire package with Clojure HOT 1
- lein unable to find cheshire on classpath HOT 1
- Security vulnerability in Jackson dependency HOT 4
- Can't convert object of type org.postgresql.util.PGobject HOT 1
- support jackson's fast number parsing/writing features HOT 1
- Update test.generative HOT 2
- Possible to support parsing copy-paste JSON? HOT 1
- Test failures with Java 21
- Deterministic parse and generate HOT 1
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 cheshire.