### Conditional JSON Parsing Example Source: https://github.com/babashka/json/blob/main/README.md Illustrates how babashka.json simplifies code that previously required conditional dispatch for different JSON libraries based on the environment (JVM Clojure vs. babashka). This avoids explicit `#?(:bb ... :clj ...)` syntax. ```clojure ;; Traditional conditional approach: #?(:bb (cheshire.core/parse-string ...) :clj (clojure.data.json/read-str ...)) ;; Simplified approach using babashka.json: (babashka.json/read-str ...) ``` -------------------------------- ### JSON Provider Selection and Configuration Source: https://github.com/babashka/json/blob/main/README.md Explains how babashka.json selects its JSON implementation and how to force a specific provider on the JVM. The library prioritizes Cheshire, Charred, JSONista, and clojure.data.json in that order. ```APIDOC babashka.json Provider Configuration: This library automatically selects a JSON implementation based on classpath availability. The order of preference is: 1. Cheshire 2. Charred 3. JSONista 4. clojure.data.json To force a specific implementation on the JVM, set the `babashka.json.provider` system property before loading the library. The value should be a symbol representing the provider: - `cheshire/cheshire` - `org.clojure/data.json` - `com.cnuernber/charred` - `metosin/jsonista` Example JVM property setting: ``` java -Dbabashka.json.provider=cheshire/cheshire -jar myapp.jar ``` Dependency Management: The library depends on `org.clojure/data.json` by default. To exclude this dependency, use the `:exclusions` option in your project's dependencies: ```clojure ;; project.clj or deps.edn :dependencies [[org.babashka/json "0.1.0"]] ; Replace with actual version :exclusions [org.clojure/data.json] ``` ``` -------------------------------- ### Unified JSON Reading and Writing in Clojure Source: https://github.com/babashka/json/blob/main/README.md Demonstrates the primary functions `read-str` and `write-str` for handling JSON data. This library aims to provide a single interface for common JSON operations, abstracting away underlying implementation differences between JVM Clojure and babashka. ```clojure ;; Reading JSON from a string (babashka.json/read-str "{\"key\": \"value\"}") ;; Writing a Clojure value to a JSON string (babashka.json/write-str {:key "value"}) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.