On Wed, 13 Mar 2019 at 00:43, Roelof Wobben <r.wobben@home.nl> wrote:
I did try to make this idea work but now im complete lost.
Right now the collection that should contain the objectNumbers is total empty anyone who can see where I went wrong.
I included my code so far.
A few things... !Paintings class methodsFor: 'instance creation' stamp: 'RoelofWobben 3/12/2019 17:26'! getImagesDataFromJSON: json | instance | instance := Painting new. (json at: #values) do: [ :artObjectJson | | painting | painting := Painting new. painting imageUrl: (json at: #name). instance addPainting: painting ]. ^ instance! ! You are adding a painting to a painting, which semantically makes no sense. i.e. where #addPainting: is sent to "instance" , that is holding a Painting. I would not expect your Painting class to have a method addPainting: Paintings should have that method. btw, Stop using "instance" as a variable name. Its as bad as variables named "a", "i", "t", "z" - it provides no semantic context. -------------------- Object subclass: #Paintings instanceVariableNames: 'paintings numbers' Paintings class instanceVariableNames: 'numbers paintings'! You've defined these variables on both the instance-side and class-side. I'll hazard a guess that you should delete the class-side definition. ---------------------------------- TBApplicationRootComponent initialize!Object subclass: #Painting instanceVariableNames: 'imageUrl' Why are you *not* storing objectNumber inside each Painting? What is the relationship between paintings and objectNumbers? Is it one-to-many or one-to-one? ------------------- !Paintings methodsFor: 'instance creation' stamp: 'RoelofWobben 3/11/2019 08:05'! initialize super initialize. numbers := OrderedCollection new! ! Why do you *not* initialize variable "paintings" to "OrderedCollection new" ? Aren't you dealing with a collection of paintings? ---------------- There is lots more confusing me here, so before going further, in a fresh new image, can you load NeoJSON and the attached fileout. Then in Playground do... collectionUrl := ' https://www.rijksmuseum.nl/api/nl/collection?key=14OGzuak&format=json&type=s... '. json := NeoJSONReader fromString: (ZnEasy get: collectionUrl) contents. paintings := Paintings fromJSON: json. paintings inspect. and then debug trace through that whole thing. Is that what you were trying to do? Or have I got the wrong end of the stick? cheers -ben