Hi Mike, Hi Gavin, I went for the category approach. Will also attach the diff of my changes to jira in a few seconds.
The AtomPub binding does not need fetch the type definitions as they come along with the response.. Best regards, Peter On 4/17/14, 5:35 PM, "Gavin Cornwell" <[email protected]> wrote: >Hi Peter, > >Yes, NSNull is one of those annoyances of parsing JSON in ObjectiveC! >What approach did you decide to go with? > >I haven¹t taken a look at your first set of changes yet (I will try to >tonight) but passing CMISSession around the binding implementation >doesn¹t sound like something we want to do to be honest. The CMISSession >classes are supposed to sit on top of the binding implementation so doing >this could introduce some interesting cyclic dependencies. > >I¹m not sure what the answer is to be honest at the moment. If we need >access to the type cache maybe that¹s an indication the one we have is in >the wrong place. The AtomPub binding must have faced a similar issue how >has it dealt with the issue you¹re seeing? > >I will try and take a look tonight and come back with something a little >more concrete. > >Regards, > >Gavin > > > >On 17 Apr 2014, at 13:48, Mike Hatfield <[email protected]> >wrote: > >> Hi Peter >> >> This JSON behaviour presumably stems from the limitation on >>NSDictionary and NSArray that they cannot contain nil objects, so NSNull >>is used instead. >> >> There seem to be two popular workarounds if the client code requires >>nil instead of NSNull: >> 1 - A category on NSDictionary, e.g. - >>(id)cmis_objectForKeyNotNull:(id)key { Š } >> 2 - A macro, e.g. NilOrObjectForKey(json, key) which would do the same >>thing. >> >> Neither of those solutions would add too much overhead, although >>clearly we would no longer benefit from modern Objective-C syntax in >>those instances. >> >> I'm not currently up-to-speed with the browser binding branch, so can't >>comment on your second issue. >> >> Regards, >> Mike >> >> On 17 Apr 2014, at 13:17, Sutter, Peter <[email protected]> wrote: >> >>> Hi there, >>> >>> I¹m facing currently an issue with [NSJSONSerialization >>>JSONObjectWithData:options:error:] and would like to hear your opinion. >>> The method returns for keys that do not have a value the NSNull object. >>> >>> E.g. when reading the repository info and the description is null on >>>the server, >>> >>> repoInfo.desc = repo[kCMISBrowserJSONRepositoryDescription]; >>> >>> >>> repoInfo.desc has the NSNull object instead of nil. Is there a better >>>way than to wrap this "dictionary[<key>]² with a helper method? >>> >>> Something like >>> >>> + (id)valueOrNil:(id)value >>> >>> { >>> >>> return value == [NSNull null] ? nil : value; >>> >>> } >>> >>> But then we have to wrap all calls when accessing the value of the >>>dictionary with such a method and this would blow up the code.. or do I >>>miss something here? >>> >>> >>> The other thing is I need to access the CMISSession within the >>>CMISBrowserUtil so that I can retrieve the type definitions (and also >>>make use of the type cache) when converting the succinctProperties. >>> >>> I could add the CMISSession as property to the CMISBrowserBaseService. >>>From there I could pass the session to the CMISBrowserUtil. Any >>>objections or even a better approach as this seems to me like a dirty >>>workaround? >>> >>> >>> Best regards, >>> >>> Peter >> >
