ios - JsonModel NSString transform null to empty string -


i using jsonmodel in application. possible prepare category jsonvaluetransformer transform nil/null nsstring empty string (@""). far when property in json response null, property in object becomes @"".

because whole api not (it's external) avoid overriding initwithdictionary in every object , use valuetransformer every jsonmodel class nsstring property , map correct string or empty string if nil/null.

after getting response, run following loop response dictionary , key.

for (id dictionary in [[responsedictionary valueforkey:@"responsekey"] allkeys] )     {            ([[responsedictionary valueforkey:@"responsekey"] valueforkey:dictionary] == [nsnull null]) ? [[responsedictionary valueforkey:@"responsekey"] setvalue:@"" forkey:dictionary] :[[responsedictionary valueforkey:@"responsekey"] setvalue:[[responsedictionary valueforkey:@"responsekey"] valueforkey:dictionary] forkey:dictionary];     } 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -