> On 27 Sep 2020, at 19:34, Roelof Wobben via Pharo-users
> <pharo-users@lists.pharo.org> wrote:
>
> Hello,
>
> In a project of mine I do this :
>
> (ZnEasy get:
> 'https://www.rijksmuseum.nl/api/nl/collection/SK-C-1368/tiles?key=14OGzuak'
> ) contents .
>
> but this is given me a bytearray.
>
> When I do the same in other languages I know like c# or ruby I get a
> dictionary like I suspect.
>
>
> Can som one explain to me why this happens with ZnEasy.
>
> Regards,
>
> Roelof
This website/webservice has an incomplete http 1.1 fallback IMHO, as it does
not set the content-type of the response - in that case the default is
application/octet-stream, hence a ByteArray.
You can see this when you ask curl to use http 1.1
$ curl -v --http1.1
https://www.rijksmuseum.nl/api/nl/collection/SK-C-1368/tiles?key=14OGzuak
You will see there is no content-type in the response. Now, curl too will
seemingly show you the expected text, but that is an assumption it cannot
actually make (it does this in a unix tradition).
Now, since we know/expect textual JSON data (apparently), you can make the
request work as follows:
(ZnEasy get:
'https://www.rijksmuseum.nl/api/nl/collection/SK-C-1368/tiles?key=14OGzuak')
contents utf8Decoded.
When you have NeoJSON load, you can parse as follows:
NeoJSONObject fromString: (ZnEasy get:
'https://www.rijksmuseum.nl/api/nl/collection/SK-C-1368/tiles?key=14OGzuak')
contents utf8Decoded.
Sven