what did I do wrong here

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

what did I do wrong here

Roelof
Hello,

I try to ask a api for some data and then display the data  I want.

But when I do :

json := (NeoJSONReader fromString: (ZnEasy get: 'https://www.rijksmuseum.nl/api/nl/collection?key=14OGzuak&format=json&type=schilderij&toppieces=True') contents).

Paintings new fromJSON:  json 


I still see a message that Paintings do not understand new.

What did I do wrong here.

I will include  a file-out of my code 


Regards, 

Roelof

Paintings.st (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: what did I do wrong here

Sven Van Caekenberghe-2
Your #fromJSON: methods should be on the class not the instance side.

> On 25 Feb 2019, at 21:52, Roelof Wobben <[hidden email]> wrote:
>
> Hello,
>
> I try to ask a api for some data and then display the data  I want.
>
> But when I do :
>
> json := (NeoJSONReader fromString: (ZnEasy get: 'https://www.rijksmuseum.nl/api/nl/collection?key=14OGzuak&format=json&type=schilderij&toppieces=True
> ') contents).
>
> Paintings new fromJSON:  json
>
>
> I still see a message that Paintings do not understand new.
>
> What did I do wrong here.
>
> I will include  a file-out of my code
>
>
> Regards,
>
> Roelof
>
> <Paintings.st>


Reply | Threaded
Open this post in threaded view
|

Re: what did I do wrong here

Roelof
Thanks,

How do I know the next time if I need to use a instance or a class method ?

That was the trick.

Roelof



Op 25-2-2019 om 22:05 schreef Sven Van Caekenberghe:
> json := (NeoJSONReader fromString: (ZnEasy get: 'https://www.rijksmuseum.nl/api/nl/collection?key=14OGzuak&format=json&type=schilderij&toppieces=True
> ') contents).
>
> Paintings new fromJSON:  json


Reply | Threaded
Open this post in threaded view
|

Re: what did I do wrong here

Sven Van Caekenberghe-2


> On 25 Feb 2019, at 22:30, Roelof Wobben <[hidden email]> wrote:
>
> Thanks,
>
> How do I know the next time if I need to use a instance or a class method ?

Instance creation happens on the class side, when your are on the instance side, your already have an instance (self) that was already created [this is by definition/design], so there is no point in creating a new instance, unless you want to make a copy or convert to something else.

> That was the trick.
>
> Roelof
>
>
>
> Op 25-2-2019 om 22:05 schreef Sven Van Caekenberghe:
>> json := (NeoJSONReader fromString: (ZnEasy get: 'https://www.rijksmuseum.nl/api/nl/collection?key=14OGzuak&format=json&type=schilderij&toppieces=True
>> ') contents).
>>
>> Paintings new fromJSON:  json
>
>