Message from discussion
Noir.response and custom java object
Received: by 10.58.19.99 with SMTP id d3mr1785331vee.32.1349376013809;
Thu, 04 Oct 2012 11:40:13 -0700 (PDT)
X-BeenThere: clojure@googlegroups.com
Received: by 10.220.148.143 with SMTP id p15ls2591701vcv.9.gmail; Thu, 04 Oct
2012 11:40:05 -0700 (PDT)
Received: by 10.52.29.225 with SMTP id n1mr1248586vdh.5.1349376005847;
Thu, 04 Oct 2012 11:40:05 -0700 (PDT)
Date: Thu, 4 Oct 2012 11:40:05 -0700 (PDT)
From: arekanderu <arekand...@gmail.com>
To: clojure@googlegroups.com
Message-Id: <197f5ffa-4ade-477f-a080-e41e66445d03@googlegroups.com>
In-Reply-To: <4471459c-436d-416b-be37-29f87366df0d@googlegroups.com>
References: <5026871c-63f1-4c58-9513-3f0dc8d6c76c@googlegroups.com>
<CAPdvrr9XK34+CiJ0z4hcfJN_Bn_y73r09zz+JMotteCy7tLEag@mail.gmail.com>
<9153ae44-b4f7-43ec-bfbb-4972529bc09d@googlegroups.com>
<f3b9ad6b-e558-459c-aa59-9ded18ff97f3@googlegroups.com>
<4471459c-436d-416b-be37-29f87366df0d@googlegroups.com>
Subject: Re: Noir.response and custom java object
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_45_29893909.1349376005421"
------=_Part_45_29893909.1349376005421
Content-Type: multipart/alternative;
boundary="----=_Part_46_16430540.1349376005421"
------=_Part_46_16430540.1349376005421
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
After adding the dependencies of noir to my own project.clj, everything
worked fine :)
I hope that noir developers will make it a bit easier soon...
On Thursday, October 4, 2012 9:26:56 PM UTC+3, arekanderu wrote:
>
> OK, the problem is that the custom encoders isn't merged with the master
> tree yet so, you need to download this branch<https://github.com/bitwalker/noir/tree/custom-json-encoding>,
> run *lein jar *at the root directory of the project and then use that jar
> file in your project dependencies. I did that by having a local maven repo<http://www.pgrs.net/2011/10/30/using-local-jars-with-leiningen/>in my project
>
> ...unfortunately though a bunch of deps are required though or else lein
> run blows up. I am still working on it to see what can i do. What a mess
>
> On Thursday, October 4, 2012 8:54:17 PM UTC+3, arekanderu wrote:
>>
>> In fact, on the latest commit, response.clj<https://github.com/bitwalker/noir/blob/master/src/noir/response.clj>does not seem to use chesire.custom anymore even though this
>> commit<https://github.com/bitwalker/noir/commit/6408d7028cae00937588b599b7c3305bb48e32fd>indicates otherwise.
>>
>> On Thursday, October 4, 2012 8:32:25 PM UTC+3, arekanderu wrote:
>>>
>>> Hi Gaz
>>>
>>> That's exactly the part that I can't figure out. Where exactly am I
>>> supposed to do that? Inside the clj where I am going to use noir.response?
>>> My apologies if my question seems silly but I am a bit brain-blocked
>>> with this.
>>>
>>> On Thursday, October 4, 2012 8:26:29 PM UTC+3, Gaz wrote:
>>>>
>>>> It seems to be using cheshire under the covers, did you add an encoder
>>>> for your class? e.g:
>>>>
>>>> (add-encoder java.awt.Color
>>>> (fn [c jsonGenerator]
>>>> (.writeString jsonGenerator (str c))))
>>>>
>>>> On Thu, Oct 4, 2012 at 12:04 PM, arekanderu <areka...@gmail.com>
>>>> wrote:
>>>> > Hello,
>>>> >
>>>> > I am not sure if i am supposed to ask a noir-related question in the
>>>> group
>>>> > but the noir issues at github is closed so i thought someone here
>>>> might
>>>> > know. I am trying to use a custom encoder with noir.response but i am
>>>> > failing to understand how.
>>>> >
>>>> > This is what I am trying to do which at the moment fails of course:
>>>> >
>>>> >>> (ns my-app.views.my-page
>>>> >>>
>>>> >>> (:require [noir.response :as resp]))
>>>> >>>
>>>> >>>
>>>> >>> (defpage "/my-page" []
>>>> >>>
>>>> >>> (let [java-object (do-something)]
>>>> >>>
>>>> >>> (resp/json java-object)))
>>>> >
>>>> >
>>>> > The error message
>>>> >
>>>> >> Cannot JSON encode object of class: class-name-here - (class
>>>> >> org.codehaus.jackson.JsonGenerationException)
>>>> >
>>>> >
>>>> > It does work however if i use gson on my java-object before i pass it
>>>> to
>>>> > resp/json but i prefer to do it without gson. I am pretty sure its
>>>> possible
>>>> > :)
>>>> >
>>>> > Thank you for any replies
>>>> >
>>>> >
>>>> > --
>>>> > You received this message because you are subscribed to the Google
>>>> > Groups "Clojure" group.
>>>> > To post to this group, send email to clo...@googlegroups.com
>>>> > Note that posts from new members are moderated - please be patient
>>>> with your
>>>> > first post.
>>>> > To unsubscribe from this group, send email to
>>>> > clojure+u...@googlegroups.com
>>>> > For more options, visit this group at
>>>> > http://groups.google.com/group/clojure?hl=en
>>>>
>>>
------=_Part_46_16430540.1349376005421
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
After adding the dependencies of noir to my own project.clj, everything wor=
ked fine :)<div><br></div><div>I hope that noir developers will make it a b=
it easier soon...<br><br>On Thursday, October 4, 2012 9:26:56 PM UTC+3, are=
kanderu wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-l=
eft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">OK, the problem =
is that the custom encoders isn't merged with the master tree yet so, you n=
eed to download <a href=3D"https://github.com/bitwalker/noir/tree/custom-js=
on-encoding" target=3D"_blank">this branch</a>, run <b>lein jar </b>at the =
root directory of the project and then use that jar file in your proje=
ct dependencies. I did that by having a <a href=3D"http://www.pgrs.net/2011=
/10/30/using-local-jars-with-leiningen/" target=3D"_blank">local maven repo=
</a> in my project<div><br></div><div>...unfortunately though a bunch of de=
ps are required though or else lein run blows up. I am still working on it =
to see what can i do. What a mess</div><div><br>On Thursday, October 4, 201=
2 8:54:17 PM UTC+3, arekanderu wrote:<blockquote class=3D"gmail_quote" styl=
e=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex=
">In fact, on the latest commit, <a href=3D"https://github.com/bitwalker/no=
ir/blob/master/src/noir/response.clj" target=3D"_blank">response.clj</a> do=
es not seem to use chesire.custom anymore even though <a href=3D"https://gi=
thub.com/bitwalker/noir/commit/6408d7028cae00937588b599b7c3305bb48e32fd" ta=
rget=3D"_blank">this commit</a> indicates otherwise.<br><br>On Thursday, Oc=
tober 4, 2012 8:32:25 PM UTC+3, arekanderu wrote:<blockquote class=3D"gmail=
_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padd=
ing-left:1ex">Hi Gaz<div><br></div><div>That's exactly the part that I can'=
t figure out. Where exactly am I supposed to do that? Inside the clj where =
I am going to use noir.response? </div><div>My apologies if my questio=
n seems silly but I am a bit brain-blocked with this.<br><br>On Thursday, O=
ctober 4, 2012 8:26:29 PM UTC+3, Gaz wrote:<blockquote class=3D"gmail_quote=
" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-le=
ft:1ex">It seems to be using cheshire under the covers, did you add an enco=
der
<br>for your class? e.g:
<br>
<br>(add-encoder java.awt.Color
<br> (fn [c jsonGenerator]
<br> (.writeString jsonGenerator (str c))))
<br>
<br>On Thu, Oct 4, 2012 at 12:04 PM, arekanderu <<a>areka...@gmail.com</=
a>> wrote:
<br>> Hello,
<br>>
<br>> I am not sure if i am supposed to ask a noir-related question in t=
he group
<br>> but the noir issues at github is closed so i thought someone here =
might
<br>> know. I am trying to use a custom encoder with noir.response but i=
am
<br>> failing to understand how.
<br>>
<br>> This is what I am trying to do which at the moment fails of course=
:
<br>>
<br>>>> (ns my-app.views.my-page
<br>>>>
<br>>>> (:require [noir.response :as resp]))
<br>>>>
<br>>>>
<br>>>> (defpage "/my-page" []
<br>>>>
<br>>>> (let [java-object (do-something)]
<br>>>>
<br>>>> (resp/json java-object)))
<br>>
<br>>
<br>> The error message
<br>>
<br>>> Cannot JSON encode object of class: class-name-here - (class
<br>>> org.codehaus.jackson.<wbr>JsonGenerationException)
<br>>
<br>>
<br>> It does work however if i use gson on my java-object before i pass=
it to
<br>> resp/json but i prefer to do it without gson. I am pretty sure its=
possible
<br>> :)
<br>>
<br>> Thank you for any replies
<br>>
<br>>
<br>> --
<br>> You received this message because you are subscribed to the Google
<br>> Groups "Clojure" group.
<br>> To post to this group, send email to <a>clo...@googlegroups.com</a=
>
<br>> Note that posts from new members are moderated - please be patient=
with your
<br>> first post.
<br>> To unsubscribe from this group, send email to
<br>> <a>clojure+u...@googlegroups.com</a>
<br>> For more options, visit this group at
<br>> <a href=3D"http://groups.google.com/group/clojure?hl=3Den" target=
=3D"_blank">http://groups.google.com/<wbr>group/clojure?hl=3Den</a>
<br></blockquote></div></blockquote></blockquote></div></blockquote></div>
------=_Part_46_16430540.1349376005421--
------=_Part_45_29893909.1349376005421--