aeson
req
Our great sponsors
aeson | req | |
---|---|---|
9 | 3 | |
1,225 | 801 | |
0.5% | - | |
7.0 | 9.4 | |
4 days ago | 2 days ago | |
Haskell | Elixir | |
GNU General Public License v3.0 or later | - |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
aeson
-
Haskell adoption is higher than I expected, what can we do to get it to top 10 languages.
Don't get me wrong, we figured it all out, and currently we use Aeson fork as we needed this: https://github.com/haskell/aeson/pull/926, as the default behaviour didn't work with Swift, and I wasn't sure if it's worth spending any time completing it...
- kodimensional :: Avoiding space leaks at all costs
-
How would aeson redesign FromJSON without intermediate Value?
Simdjson-based Hermes is able to decode JSON significantly faster while still using an intermediate representation: https://github.com/haskell/aeson/pull/923
- List of upcoming breaking changes
-
The aeson vulnerability has been fixed in aeson-2.0.1.0
Ah, I see you are working on this already, thank you: https://github.com/haskell/aeson/pull/883
-
Text Maintainers: text-utf8 migration discussion - Haskell Foundation
Similar scan is already in aeson https://github.com/haskell/aeson/blob/master/src/Data/Aeson/Parser/Internal.hs#L322-L335 where the unsafeDecodeASCII is used I mentioned in my previous comment.
-
High-performance JSON codec
I'd be curious to see the benchmarks with the cffi flag enabled. aeson by default uses Haskell instead of C and this results in a pretty massive slowdown - the benchmark in that PR shows FFI being 12x faster.
Well, the aeson’s ffi code is written by me: https://github.com/haskell/aeson/commit/2f24e555d86a36fdda6d4cad79976004b382ab3b
req
-
How to implement a disk cache plugin for Elixir's Req HTTP client?
> no error checking at all (I assume it just panics or exception?)
In Elixir, bang functions per convention will raise on error. `get/2` will return error tuples allowing you to handle errors. In fact, get!/2 just calls get/2 and raises for you[^1].
> no mention of JSON at all
Req is the most "batteries included" Elixir HTTP lib out there. I can't speak for Wojtek, but I believe the goal was to make Req extremely easy to use in scripting or things like LiveBook without having to do much work. That being said, the automatic decoding is mentioned in the readme[^2] and the docs[^3].
> if "body" is JSON, how do you even get the raw body, or can you?
Per the docs[^3], you can either skip with a `:raw` option, or just build your own request using only the steps you want.
> just seems over engineered/over fitted whatever you want to call it.
Fair, but again, this library is designed to be on that end of the spectrum. There are plenty of other libraries further down the stack that you can use. I am partial to Finch[^4], upon which Req is built.
To address the sibling comment about "Let it Crash", the language allows you to easily recover from crashes, but that is for resiliency, not error handling. In practice you would use the non-bang get/2, pattern match on the response, handle any errors, perhaps use Kernel.get_in/2 to safely traverse the map, etc. The example provided by the author is not "production ready".
[^1]: https://github.com/wojtekmach/req/blob/v0.3.11/lib/req.ex#L3...
> no error checking at all
Functions that raise always end in `!` in Elixir, or at least they should. Most have alternatives that return error tuples instead which you can pattern match on (this is what I recommend). You can read the docs for `get/2` (as opposed to `get!/2` which raises) here: https://hexdocs.pm/req/Req.html#get/2.
A common pattern is for the `!` version to call the version that doesn't raise, check the result, and raise on error, which is the case here: https://github.com/wojtekmach/req/blob/9de30de0df481ee557ccc...
> and if "body" is JSON, how do you even get the raw body, or can you?
You would set `decode: false` when calling `get!/2: https://hexdocs.pm/req/Req.html#new/1. You can also set this as configuration with https://hexdocs.pm/req/Req.html#default_options/1.
As a closing note I'll mention that Req is intended to be a very high-level, scripting-friendly requests library, similar to Requests in Python. If you don't want conveniences like Req provides, you can either turn them off or use something different, like Finch (which Req is based on, https://github.com/sneako/finch). Other than Req and Finch I'm personally only familiar with HTTPoison, which is significantly older than all of the libraries derived from Mint (like Finch and Req, https://github.com/elixir-mint/mint) but still works. There are many others though, like Gun and Tesla and such.
What are some alternatives?
aeson-coerce
alternative-vector - Use vectors with many and some, instead of lists
aeson-utils - Utilities for working with aeson.
aeson-applicative - define To/From JSON instances from one applicative definition
req - An HTTP client library
tmp-postgres - Create temporary postgres instances
android-lint-summary - Prettier display of Android Lint issues
gc-monitoring-wai - a wai application to show `GHC.Stats.GCStats`
jsaddle - JavaScript interface that works with GHCJS or GHC
inquire
aeson-lens - Lens of Aeson
clock-extras