Here a stripped down example
d := { 'bank' -> 'Région Genève Rhône'. } asDictionary.
teapot := Teapot configure: {
#defaultOutput -> #json.
#port -> 8081.
#debugMode -> true
}.
teapot
GET: '/api/d' -> d;
exception: KeyNotFound -> (TeaResponse notFound body: 'asd');
start.
(ZnEasy get: 'http://localhost:8081/api/d') entity string.
Pharo 4.0 / Teapot
BW,
Volkert
Am 01.05.2015 um 15:35 schrieb Sven Van Caekenberghe:
On 01 May 2015, at 15:15, volkert <volk...@komponentenwerkstatt.de> wrote:
I thought UTF-8 is the default encoding in case JSON Documents, and so for the
Content-Type: application/json.
I added "setCharSetUTF8" this Teapot-Output and all works fine now. :-)
Fine, but I still think this is strange, it should work by default too.
But to understand what went wrong, I need an example (server+client) that I can
run.
Danke,
Volkert
Am 01.05.2015 um 14:20 schrieb Norbert Hartl:
You need to look at the headers of the request. I would assume the sender sets
an Content-Type: application/json without charset. In that moment it is
uncertain what has to be done because the server needs to assume what charset
it might be and this tasks seldomly works out good.
In order to make it work set a content type of your entity this way
ZnMimeType applicationJson setCharSetUTF8
Now you send a Content-Type of application/json;charset=utf-8 and the server
knows which character decoder to use. That should be it. So please always
assign a char set to your sending data to make it more reliable what happens on
the other end.
hope this helps,
Norbert
Am 01.05.2015 um 14:13 schrieb volkert <volk...@komponentenwerkstatt.de>:
I tried ZnClient new get: 'http://<removed>/api/atm/801813'; yourself and got.
<fdchdjab.png>
This is the Doc i see in Firefox.
<fceagiec.png>
The JSON is served with ZnServer / Teapot. ;-)
Volkert
Am 01.05.2015 um 12:21 schrieb Sven Van Caekenberghe:
Hi Volkert,
Tip 1: use ZnClient and inspect the response in detail, more specifically to
see whether the response content type specifies the encoding.
ZnClient new get: '
http://
<removed>/api/atm/801813'; yourself.
Tip 2: you could try to force override the default encoding using
ZnDefaultCharacterEncoder (see the class comment).
But recent Zn code defaults to UTF8 (see #withDefaultUTF8Decoding: and
#withDefaultUTF8Encoding:). So I am curious to see the response headers.
HTH,
Sven
On 01 May 2015, at 11:54, volkert <volk...@komponentenwerkstatt.de>
wrote:
Dear all,
i am trying to get a JSON Document with ZnEasy. The Document is UTF-8 encoded.
(ZnEasy get: '
http://
<removed>/api/atm/801813') entity string.
<gccacjeh.png>
Any hints?
Volkert