Hey guys, I'm toying with the idea of a Pharo implementation of ActivityStreams ( https://www.w3.org/TR/activitystreams-core/#introduction) which is based on a subset of JSON called JSON-LD (for "linked data").
While I do not believe this would entail creating a whole JSON-LD implementation, I do have a question about how to implement reading/writing/mapping to and from the core set of object types in the specification. I am aware that giving any class #neoJsonMapping allows one to define the specifics of the mapping to and from objects of that class (I think this is super cool, by the way). The issue with ActivityStreams objects is that the "type" of object they represent is in the JSON itself as the property "type," for example: ``` { "@context": "https://www.w3.org/ns/activitystreams", "name": "A simple note", "type": "Note", "id": "http://www.test.example/notes/1", "content": "A simple note", "replies": { "type": "Collection", "totalItems": 1, "items": [ { "name": "A response to the note", "type": "Note", "content": "A response to the note", "inReplyTo": "http://www.test.example/notes/1" } ] } } ``` This refers to a top level ActivityStream object of type "Note" which we maybe want to parse into something like `ASNote`. My core question is this: how can we get a NeoJSONReader to determine which type of object to create by checking for a "type" property as soon as possible in the process? Because this property can show up in any order, we won't know what type of object to create until it is encountered. What is the best strategy there? Does the complexity suggest that we should simply parse incoming ActivityStream objects into the collection-and-dict default mapping and deal with creating the appropriate objects after that? In this case we could still use the custom mapping for the writing, which is not a problem since the "type" field will be associated with the class (ie, ASNote class >> #type will respond with 'Note' and we can go from there). Any thoughts or suggestions much appreciated! -- Eric