chemistry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gavin Cornwell <>
Subject Re: Browser binding implementation
Date Thu, 17 Apr 2014 15:35:40 GMT
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.



On 17 Apr 2014, at 13:48, Mike Hatfield <> 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 <> 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

View raw message