Questions tagged [cheshire]

Cheshire is fast JSON encoding, based off of clj-json and clojure-json, with additional features like Date/UUID/Set/Symbol encoding and SMILE support.

Cheshire is fast encoding, based off of clj-json and clojure-json, with additional features like Date/UUID/Set/Symbol encoding and SMILE support.

https://github.com/dakrone/cheshire

17 questions
5
votes
1 answer

Why is pmap|reducers/map not using all cpu cores?

I'm trying to parse a file with a million lines, each line is a json string with some information about a book (author, contents etc). I'm using iota to load the file, as my program throws an OutOfMemoryError if I try to use slurp. I'm also using…
eugecm
  • 1,189
  • 8
  • 14
5
votes
2 answers

Clojure JSON: Exception: com.fasterxml.jackson.core.JsonGenerationException: Cannot JSON encode object of class:

I am trying to create a node in my Neo4j datastore using clojure neocons and I am running into an error that I think is related to formatting json: Exception: com.fasterxml.jackson.core.JsonGenerationException: Cannot JSON encode object of class:…
Benjamin McFerren
  • 822
  • 5
  • 21
  • 36
3
votes
1 answer

Encode a Clojure byte array to JSON

I need to encode a Clojure byte array to JSON. I have been trying to do this using Cheshire's add-encoder function, like this: (add-encoder [Ljava.lang.Byte encode-seq) The problem is the reader always complains about an unmatched delimiter. I'm…
ChrisM
  • 2,128
  • 1
  • 23
  • 41
2
votes
2 answers

How to convert Java String to EDN object?

In Clojure, I am using 'generate-string' function of cheshire (https://github.com/dakrone/cheshire) library to convert EDN to JSON. It works fine if I call it directly using EDN data in Clojure i.e. (defn generate-json-string (generate-string…
ppp456878
  • 155
  • 8
2
votes
4 answers

How to adapt the IReduceInit from next.jdbc to stream JSON using cheshire to a HTTP response using ring

tl;dr how to turn an IReduceInit into a lazy-seq of transformed values I have a database query which yields a reasonably large dataset for live pivoting on the client (million or two rows, 25 attributes - no problem for a modern laptop). My…
pete23
  • 2,204
  • 23
  • 28
2
votes
1 answer

How can I make JSON responses be pretty-printed when using Rook?

I am using Rook framework for web services. I want to make API responses be pretty-printed. It seems that the response encoding is all handled by the wrap-restful-format function from ring.middleware.format. So I tried to replace the…
amoe
  • 4,473
  • 4
  • 31
  • 51
1
vote
2 answers

Decode, in clojure, a JSON, clojure.data.json & cheshire.core, can't custom decode w/cheshire

My project parses JSONs, with a read/write library, called: cheshire.core I was having problems, trying to get the decode (func) to work, so I started messing around with: data.json My JSON contains data that consists of a field named "zone" this…
rezwits
  • 835
  • 7
  • 12
1
vote
0 answers

Clojure - url "format" in json response

I write a REST API with Clojure liberator, and I have this function, in order to build the URL: (defn build-entry-url [request] (URL. (format "%s://%s:%s%s" (name (:scheme request)) (:server-name request) …
Édipo Féderle
  • 4,169
  • 5
  • 31
  • 35
0
votes
2 answers

Parsing to json with Cheshire - generate- string and parse-string

I am trying to export json-schema to be used outside of Clojure in javascript. I am able to generate this: {:type "object", :properties {:$class {:type "string"}, :name {:type "string"}, :clauseId {:type "string"}, …
tbrooke
  • 2,137
  • 2
  • 17
  • 25
0
votes
4 answers

How to represent non-standard java objects when encoding to JSON in Clojure?

I have a standard clojure map of things. The keys are keywords, and the values are arbitrary values. They can be nil, numbers, strings, or any other kind of JVM object/class. I need to know how to encode this map into JSON, so that "normal" values…
djhaskin987
  • 9,741
  • 4
  • 50
  • 86
0
votes
1 answer

How to print EDN output in JSON format using Cheshire custom encoder

I am newbie with Clojure and I am trying to print EDN output to valid JSON format using Cheshire custom encoder for classes defined in java. My EDN file: {:xyz #XyzBuilder "testString"} Clojure code: (defn getXyz [str] (.getXyz (XyzBuilder.)…
ppp456878
  • 155
  • 8
0
votes
1 answer

How can I convert EDN output to JSON which has custom readers defined

In Clojure, I am using 'generate-string' function of cheshire (https://github.com/dakrone/cheshire) library to convert EDN to JSON. It works fine for EDN without custom readers. For ex: sample.edn: {:foo "bar" :baz {:eggplant [1 2…
ppp456878
  • 155
  • 8
0
votes
1 answer

Convert from data.json to cheshire

I am completely new to Clojure. I still struggle with reading functions sometimes. I am trying to change this function to use checkshire. Here is my attempt : defn- json->messages [json] (let [records (:amazon.aws.sqs/records…
user4148098
0
votes
1 answer

How to pass data with GET request?

I want to pass form data with GET request. I have success with this curl: curl http://sample.com -d 'action=login_request&user_name=balvan' but I need to pass that same stuff from -d. with this function call: (http-client/request …
user11274258
0
votes
1 answer

check resultset for emptiness in clojure jdbc

i'm using clojure with jdbc, compojure, cheshire, postgresql, c3p0, tryin make REST. When i'm using this code as handler (defn get-document [id] (sql/query (db-connection) ["select * from document where id = cast(? as…
Bartosso
  • 3
  • 1
1
2